#13696: Admin Edit Inline templates only output hidden field for PK when
inline_admin_form.has_auto_field
--------------------------------------------+-------------------------------
Reporter: [email protected] | Owner: nobody
Status: reopened | Milestone:
Component: django.contrib.admin | Version: 1.2
Resolution: | Keywords: inline templates
Stage: Unreviewed | Has_patch: 0
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
--------------------------------------------+-------------------------------
Comment (by wolever):
As a warning: the “obvious” work around for this is to have custom ID
fields “pretend” to be auto fields by doing something like this:
{{{
def contribute_to_class(...): # XXX BAD XXX
cls._meta.has_auto_field = True
ls._meta.auto_field = self
}}}
However, this doesn't quite work either, because line 525 of
`/Users/wolever/Verso/Repos/web/env/massuni-web/lib/python2.6/site-
packages/django/db/models/base.py` in `save_base`(`update_pk =
bool(meta.has_auto_field and not pk_set)`), sets the `update_pk` flag,
which essentially causes:
{{{
if update_pk:
instance.id = get_last_inserted_id()
}}}
And, at least with the SQLite backend, the result of
`get_last_inserted_id` is the row number (or similar), *not* the value of
the `id` field.
So, in short, this issue can't be hacked around by setting
`has_auto_field`.
--
Ticket URL: <http://code.djangoproject.com/ticket/13696#comment:6>
Django <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.