#8648: Admin ignores to_field on ForeignKey
--------------------------------------+-------------------------------------
Reporter: kmtracey | Owner: nobody
Status: new | Milestone: 1.0
Component: Admin interface | Version: SVN
Resolution: | Keywords:
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
--------------------------------------+-------------------------------------
Comment (by kmtracey):
With 868.4.diff I cannot bring up the list of Inventories -- I get:
{{{
Environment:
Request Method: GET
Request URL: http://localhost:8000/admin/selfref/inventory/
Django Version: 1.0-beta_2-SVN-8818
Python Version: 2.5.2
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'django.contrib.sitemaps',
'django.contrib.flatpages',
'playground.selfref']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.doc.XViewMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware')
Template error:
In template
d:\u\kmt\django\trunk\django\contrib\admin\templates\admin\change_list.html,
error at line 34
Caught an exception while rendering: getattr(): attribute name must be
string
24 : {% if cl.has_filters %}
25 : <div id="changelist-filter">
26 : <h2>{% trans 'Filter' %}</h2>
27 : {% for spec in cl.filter_specs %}
28 : {% admin_list_filter cl spec %}
29 : {% endfor %}
30 : </div>
31 : {% endif %}
32 : {% endblock %}
33 :
34 : {% block result_list %} {% result_list cl %} {% endblock %}
35 : {% block pagination %}{% pagination cl %}{% endblock %}
36 : </div>
37 : </div>
38 : {% endblock %}
39 :
Traceback:
File "d:\u\kmt\django\trunk\django\core\handlers\base.py" in get_response
86. response = callback(request, *callback_args,
**callback_kwargs)
File "d:\u\kmt\django\trunk\django\contrib\admin\sites.py" in root
173. return self.model_page(request, *url.split('/', 2))
File "d:\u\kmt\django\trunk\django\views\decorators\cache.py" in
_wrapped_view_func
44. response = view_func(request, *args, **kwargs)
File "d:\u\kmt\django\trunk\django\contrib\admin\sites.py" in model_page
192. return admin_obj(request, rest_of_url)
File "d:\u\kmt\django\trunk\django\contrib\admin\options.py" in __call__
188. return self.changelist_view(request)
File "d:\u\kmt\django\trunk\django\contrib\admin\options.py" in
changelist_view
656. ], context,
context_instance=template.RequestContext(request))
File "d:\u\kmt\django\trunk\django\shortcuts\__init__.py" in
render_to_response
18. return HttpResponse(loader.render_to_string(*args, **kwargs),
**httpresponse_kwargs)
File "d:\u\kmt\django\trunk\django\template\loader.py" in render_to_string
107. return t.render(context_instance)
File "d:\u\kmt\django\trunk\django\template\__init__.py" in render
176. return self.nodelist.render(context)
File "d:\u\kmt\django\trunk\django\template\__init__.py" in render
768. bits.append(self.render_node(node, context))
File "d:\u\kmt\django\trunk\django\template\debug.py" in render_node
71. result = node.render(context)
File "d:\u\kmt\django\trunk\django\template\loader_tags.py" in render
97. return compiled_parent.render(context)
File "d:\u\kmt\django\trunk\django\template\__init__.py" in render
176. return self.nodelist.render(context)
File "d:\u\kmt\django\trunk\django\template\__init__.py" in render
768. bits.append(self.render_node(node, context))
File "d:\u\kmt\django\trunk\django\template\debug.py" in render_node
71. result = node.render(context)
File "d:\u\kmt\django\trunk\django\template\loader_tags.py" in render
97. return compiled_parent.render(context)
File "d:\u\kmt\django\trunk\django\template\__init__.py" in render
176. return self.nodelist.render(context)
File "d:\u\kmt\django\trunk\django\template\__init__.py" in render
768. bits.append(self.render_node(node, context))
File "d:\u\kmt\django\trunk\django\template\debug.py" in render_node
71. result = node.render(context)
File "d:\u\kmt\django\trunk\django\template\loader_tags.py" in render
24. result = self.nodelist.render(context)
File "d:\u\kmt\django\trunk\django\template\__init__.py" in render
768. bits.append(self.render_node(node, context))
File "d:\u\kmt\django\trunk\django\template\debug.py" in render_node
71. result = node.render(context)
File "d:\u\kmt\django\trunk\django\template\loader_tags.py" in render
24. result = self.nodelist.render(context)
File "d:\u\kmt\django\trunk\django\template\__init__.py" in render
768. bits.append(self.render_node(node, context))
File "d:\u\kmt\django\trunk\django\template\debug.py" in render_node
81. raise wrapped
Exception Type: TemplateSyntaxError at /admin/selfref/inventory/
Exception Value: Caught an exception while rendering: getattr(): attribute
name must be string
Original Traceback (most recent call last):
File "d:\u\kmt\django\trunk\django\template\debug.py", line 71, in
render_node
result = node.render(context)
File "d:\u\kmt\django\trunk\django\template\__init__.py", line 915, in
render
dict = func(*args)
File
"d:\u\kmt\django\trunk\django\contrib\admin\templatetags\admin_list.py",
line 238, in result_list
'results': list(results(cl))}
File
"d:\u\kmt\django\trunk\django\contrib\admin\templatetags\admin_list.py",
line 233, in results
yield list(items_for_result(cl,res))
File
"d:\u\kmt\django\trunk\django\contrib\admin\templatetags\admin_list.py",
line 225, in items_for_result
result_id = repr(force_unicode(getattr(result, cl.to_field)))[1:]
TypeError: getattr(): attribute name must be string
}}}
`{% result_list cl %}` is highlighted on line 34. The admin.py I have is:
{{{
from django.contrib import admin
from selfref.models import Inventory
class InventoryAdmin(admin.ModelAdmin):
list_display = ('name', 'barcode', 'parent')
raw_id_fields = ('parent',)
admin.site.register(Inventory, InventoryAdmin)
}}}
but the error persists even if I don't customize the !ModelAdmin at all
(`admin.site.register(Inventory)`).
--
Ticket URL: <http://code.djangoproject.com/ticket/8648#comment:17>
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
-~----------~----~----~----~------~----~------~--~---