#8719: KeyError on save of model with inline-edited ForeignKey with non-standard
primary key
--------------------------------------+-------------------------------------
Reporter: jonloyens | Owner: nobody
Status: new | Milestone: 1.0
Component: Admin interface | Version: SVN
Resolution: | Keywords:
Stage: Unreviewed | Has_patch: 0
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
--------------------------------------+-------------------------------------
Comment (by kmtracey):
Hi Brian, tried it for this case and it's got a problem. I can't even get
to the change page for a model with explicitly specified PK fields. I get
an `AttributeError 'CluesFormFormSet' object has no attribute
'_pk_field'`, traceback is:
{{{
Environment:
Request Method: GET
Request URL: http://lbox:8000/admin/crossword/entries/125408/
Django Version: 1.0-beta_2-SVN-8752
Python Version: 2.5.1
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.admin',
'django.contrib.admindocs',
'django.contrib.sites',
'django.contrib.humanize',
'xword.crossword']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.doc.XViewMiddleware')
Traceback:
File "/home/kmt/tmp/django/trunk/django/core/handlers/base.py" in
get_response
86. response = callback(request, *callback_args,
**callback_kwargs)
File "/home/kmt/tmp/django/trunk/django/contrib/admin/sites.py" in root
173. return self.model_page(request, *url.split('/', 2))
File "/home/kmt/tmp/django/trunk/django/views/decorators/cache.py" in
_wrapped_view_func
44. response = view_func(request, *args, **kwargs)
File "/home/kmt/tmp/django/trunk/django/contrib/admin/sites.py" in
model_page
192. return admin_obj(request, rest_of_url)
File "/home/kmt/tmp/django/trunk/django/contrib/admin/options.py" in
__call__
196. return self.change_view(request, unquote(url))
File "/home/kmt/tmp/django/trunk/django/db/transaction.py" in
_commit_on_success
238. res = func(*args, **kw)
File "/home/kmt/tmp/django/trunk/django/contrib/admin/options.py" in
change_view
596. formset = FormSet(instance=obj)
File "/home/kmt/tmp/django/trunk/django/forms/models.py" in __init__
362. super(BaseInlineFormSet, self).__init__(data, files,
prefix=prefix or self.rel_name)
File "/home/kmt/tmp/django/trunk/django/forms/models.py" in __init__
256. super(BaseModelFormSet, self).__init__(**defaults)
File "/home/kmt/tmp/django/trunk/django/forms/formsets.py" in __init__
67. self._construct_forms()
File "/home/kmt/tmp/django/trunk/django/forms/models.py" in
_construct_forms
368. super(BaseInlineFormSet, self)._construct_forms()
File "/home/kmt/tmp/django/trunk/django/forms/formsets.py" in
_construct_forms
76. self.forms.append(self._construct_form(i))
File "/home/kmt/tmp/django/trunk/django/forms/formsets.py" in
_construct_form
96. self.add_fields(form, i)
File "/home/kmt/tmp/django/trunk/django/forms/models.py" in add_fields
389. if isinstance(self._pk_field, OneToOneField):
Exception Type: AttributeError at /admin/crossword/entries/125408/
Exception Value: 'CluesFormFormSet' object has no attribute '_pk_field'
}}}
My Clues model has primary key defined like so:
{{{
class Clues(models.Model):
ID = models.AutoField(primary_key=True)
etc...
}}}
Verified the patch does fix #8694 and #8695 though.
--
Ticket URL: <http://code.djangoproject.com/ticket/8719#comment:4>
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
-~----------~----~----~----~------~----~------~--~---