Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#5533 closed (worksforme)

allow create to pass foreignkey_id

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


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.

Attachments (0)

Change History (2)

comment:1 Changed 7 years ago by ubernostrum

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to worksforme
  • Status changed from new to closed

Testing with my blog code against current Django trunk:

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

Markign "worksforme".

comment:2 Changed 7 years ago by ubernostrum

Also, this worked:

>>> e = Entry.objects.create(author_id=1, ...

Add Comment

Modify Ticket

Change Properties
<Author field>
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.