#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):
Change page still won't display, it's back to !KeyError, but during
rendering of the form vs. attempt to save it:
{{{
Environment:
Request Method: GET
Request URL: http://lbox:8000/admin/crossword/entries/33616/
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')
Template error:
In template
/home/kmt/tmp/django/trunk/django/contrib/admin/templates/admin/edit_inline/tabular.html,
error at line 18
Caught an exception while rendering: "Key 'ID' not found in Form"
8 : <table>
9 : <thead><tr>
10 : {% for field in inline_admin_formset.fields %}
11 : {% if not field.is_hidden %}
12 : <th {% if forloop.first %}colspan="2"{% endif %}>{{
field.label|capfirst|escape }}</th>
13 : {% endif %}
14 : {% endfor %}
15 : {% if inline_admin_formset.formset.can_delete %}<th>{% trans
"Delete?" %}</th>{% endif %}
16 : </tr></thead>
17 :
18 : {% for inline_admin_form in inline_admin_formset %}
19 :
20 : <tr class="{% cycle row1,row2 %} {% if
inline_admin_form.original or inline_admin_form.show_url %}has_original{%
endif %}">
21 :
22 : <td class="original">
23 : {% if inline_admin_form.original or
inline_admin_form.show_url %}<p>
24 : {% if inline_admin_form.original %} {{
inline_admin_form.original }}{% endif %}
25 : {% if inline_admin_form.show_url %}<a
href="../../../r/{{ inline_admin_form.original.content_type_id }}/{{
inline_admin_form.original.id }}/">{% trans "View on site" %}</a>{% endif
%}
26 : </p>{% endif %}
27 : {{ inline_admin_form.pk_field.field }}
28 : {% spaceless %}
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
622. return self.render_change_form(request, context,
change=True, obj=obj)
File "/home/kmt/tmp/django/trunk/django/contrib/admin/options.py" in
render_change_form
404. ], context,
context_instance=template.RequestContext(request))
File "/home/kmt/tmp/django/trunk/django/shortcuts/__init__.py" in
render_to_response
18. return HttpResponse(loader.render_to_string(*args, **kwargs),
**httpresponse_kwargs)
File "/home/kmt/tmp/django/trunk/django/template/loader.py" in
render_to_string
107. return t.render(context_instance)
File "/home/kmt/tmp/django/trunk/django/template/__init__.py" in render
176. return self.nodelist.render(context)
File "/home/kmt/tmp/django/trunk/django/template/__init__.py" in render
756. bits.append(self.render_node(node, context))
File "/home/kmt/tmp/django/trunk/django/template/debug.py" in render_node
71. result = node.render(context)
File "/home/kmt/tmp/django/trunk/django/template/loader_tags.py" in render
97. return compiled_parent.render(context)
File "/home/kmt/tmp/django/trunk/django/template/__init__.py" in render
176. return self.nodelist.render(context)
File "/home/kmt/tmp/django/trunk/django/template/__init__.py" in render
756. bits.append(self.render_node(node, context))
File "/home/kmt/tmp/django/trunk/django/template/debug.py" in render_node
71. result = node.render(context)
File "/home/kmt/tmp/django/trunk/django/template/loader_tags.py" in render
97. return compiled_parent.render(context)
File "/home/kmt/tmp/django/trunk/django/template/__init__.py" in render
176. return self.nodelist.render(context)
File "/home/kmt/tmp/django/trunk/django/template/__init__.py" in render
756. bits.append(self.render_node(node, context))
File "/home/kmt/tmp/django/trunk/django/template/debug.py" in render_node
71. result = node.render(context)
File "/home/kmt/tmp/django/trunk/django/template/loader_tags.py" in render
24. result = self.nodelist.render(context)
File "/home/kmt/tmp/django/trunk/django/template/__init__.py" in render
756. bits.append(self.render_node(node, context))
File "/home/kmt/tmp/django/trunk/django/template/debug.py" in render_node
71. result = node.render(context)
File "/home/kmt/tmp/django/trunk/django/template/defaulttags.py" in render
148. nodelist.append(node.render(context))
File "/home/kmt/tmp/django/trunk/django/template/loader_tags.py" in render
123. return t.render(context)
File "/home/kmt/tmp/django/trunk/django/template/__init__.py" in render
176. return self.nodelist.render(context)
File "/home/kmt/tmp/django/trunk/django/template/__init__.py" in render
756. bits.append(self.render_node(node, context))
File "/home/kmt/tmp/django/trunk/django/template/debug.py" in render_node
81. raise wrapped
Exception Type: TemplateSyntaxError at /admin/crossword/entries/33616/
Exception Value: Caught an exception while rendering: "Key 'ID' not found
in Form"
Original Traceback (most recent call last):
File "/home/kmt/tmp/django/trunk/django/template/debug.py", line 71, in
render_node
result = node.render(context)
File "/home/kmt/tmp/django/trunk/django/template/defaulttags.py", line
148, in render
nodelist.append(node.render(context))
File "/home/kmt/tmp/django/trunk/django/template/debug.py", line 87, in
render
output = force_unicode(self.filter_expression.resolve(context))
File "/home/kmt/tmp/django/trunk/django/template/__init__.py", line 523,
in resolve
obj = self.var.resolve(context)
File "/home/kmt/tmp/django/trunk/django/template/__init__.py", line 664,
in resolve
value = self._resolve_lookup(context)
File "/home/kmt/tmp/django/trunk/django/template/__init__.py", line 699,
in _resolve_lookup
current = current()
File "/home/kmt/tmp/django/trunk/django/contrib/admin/helpers.py", line
129, in pk_field
return AdminField(self.form, self.formset._pk_field.name, False)
File "/home/kmt/tmp/django/trunk/django/contrib/admin/helpers.py", line
72, in __init__
self.field = form[field] # A django.forms.BoundField instance
File "/home/kmt/tmp/django/trunk/django/forms/forms.py", line 105, in
__getitem__
raise KeyError('Key %r not found in Form' % name)
KeyError: "Key 'ID' not found in Form"
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/8719#comment:6>
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
-~----------~----~----~----~------~----~------~--~---