#8799: .save() and .objects.create() does not set the primary key when the model
has an explicit primary key field
------------------------------------------+---------------------------------
Reporter: [EMAIL PROTECTED] | Owner: nobody
Status: closed | Milestone:
Component: Database wrapper | Version:
Resolution: invalid | Keywords:
Stage: Unreviewed | Has_patch: 0
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
------------------------------------------+---------------------------------
Changes (by Daniel Pope <[EMAIL PROTECTED]>):
* status: new => closed
* needs_better_patch: => 0
* resolution: => invalid
* needs_tests: => 0
* needs_docs: => 0
Comment:
If you don't use {{{AutoField}}}, Django doesn't know that it needs to
update the field after saving.
It assumes that you will always provide a value for the primary key, and
if you don't, that you'll receive an {{{OperationError}}} from the DB-API.
Because you've specified AUTO_INCREMENT in the database (or SQLite does
that anyway), you aren't getting that error - the database is filling in a
value behind Django's back.
Effectively this is just a mismatch between your database schema and your
model definition.
--
Ticket URL: <http://code.djangoproject.com/ticket/8799#comment:1>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---