Opened 17 years ago

Closed 17 years ago

Last modified 17 years ago

#5533 closed (worksforme)

allow create to pass foreignkey_id

Reported by: David Cramer Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

MyModel.objects.create() should allow to you to pass myforeignkey_id as you could in .get().

The reasons for this are obvious. Inserting a row into a database, where you don't have a module instance of the foreign key, but just the id value.

You could use MyForeignKey(id=x) and pass this, but that's hackish.

Change History (2)

comment:1 by James Bennett, 17 years ago

Resolution: worksforme
Status: newclosed

Testing with my blog code against current Django trunk:

>>> e = Entry(author_id=1, ...)
>>> e.author
<User: james>

Markign "worksforme".

comment:2 by James Bennett, 17 years ago

Also, this worked:

>>> e = Entry.objects.create(author_id=1, ...
Note: See TracTickets for help on using tickets.
Back to Top