Opened 7 years ago

Closed 7 years ago

Last modified 4 years ago

#8324 closed (fixed)

admin list display is broken

Reported by: tobias Owned by: brosner
Component: contrib.admin Version: master
Severity: Keywords:
Cc: brosner Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

[8352] breaks simple list display. to reproduce,

# models.py
class Site(models.Model):
	name = models.CharField(max_length=255)
	
	def __unicode__(self):
		return self.name

# admin.py
from django.contrib import admin
from visitdb import models as visitdb

admin.site.register(visitdb.Site)

go to /admin, and click on Site.

Environment:

Request Method: GET
Request URL: http://localhost:8000/django-admin/visitdb/site/
Django Version: 1.0-alpha_2-SVN-8352
Python Version: 2.5.2
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'django.contrib.humanize',
 'visitdb',
 'photologue']
Installed Middleware:
('visitdb.middleware.RequestAttributeSetup',
 'django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.doc.XViewMiddleware',
 'visitdb.middleware.StandardViewKwargsMiddleware')


Template error:
In template /home/tobias/caktus/eclipse-workspace/blueridge_visit_database/django/contrib/admin/templates/admin/change_list.html, error at line 34
   Caught an exception while rendering: local variable 'attr' referenced before assignment
   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 "/home/tobias/caktus/eclipse-workspace/blueridge_visit_database/django/core/handlers/base.py" in get_response
  86.                 response = callback(request, *callback_args, **callback_kwargs)
File "/home/tobias/caktus/eclipse-workspace/blueridge_visit_database/django/contrib/admin/sites.py" in root
  172.                 return self.model_page(request, *url.split('/', 2))
File "/home/tobias/caktus/eclipse-workspace/blueridge_visit_database/django/views/decorators/cache.py" in _wrapped_view_func
  44.         response = view_func(request, *args, **kwargs)
File "/home/tobias/caktus/eclipse-workspace/blueridge_visit_database/django/contrib/admin/sites.py" in model_page
  189.         return admin_obj(request, rest_of_url)
File "/home/tobias/caktus/eclipse-workspace/blueridge_visit_database/django/contrib/admin/options.py" in __call__
  267.             return self.changelist_view(request)
File "/home/tobias/caktus/eclipse-workspace/blueridge_visit_database/django/contrib/admin/options.py" in changelist_view
  719.         ], context, context_instance=template.RequestContext(request))
File "/home/tobias/caktus/eclipse-workspace/blueridge_visit_database/django/shortcuts/__init__.py" in render_to_response
  18.     return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
File "/home/tobias/caktus/eclipse-workspace/blueridge_visit_database/django/template/loader.py" in render_to_string
  107.     return t.render(context_instance)
File "/home/tobias/caktus/eclipse-workspace/blueridge_visit_database/django/template/__init__.py" in render
  176.         return self.nodelist.render(context)
File "/home/tobias/caktus/eclipse-workspace/blueridge_visit_database/django/template/__init__.py" in render
  751.                 bits.append(self.render_node(node, context))
File "/home/tobias/caktus/eclipse-workspace/blueridge_visit_database/django/template/debug.py" in render_node
  71.             result = node.render(context)
File "/home/tobias/caktus/eclipse-workspace/blueridge_visit_database/django/template/loader_tags.py" in render
  97.         return compiled_parent.render(context)
File "/home/tobias/caktus/eclipse-workspace/blueridge_visit_database/django/template/__init__.py" in render
  176.         return self.nodelist.render(context)
File "/home/tobias/caktus/eclipse-workspace/blueridge_visit_database/django/template/__init__.py" in render
  751.                 bits.append(self.render_node(node, context))
File "/home/tobias/caktus/eclipse-workspace/blueridge_visit_database/django/template/debug.py" in render_node
  71.             result = node.render(context)
File "/home/tobias/caktus/eclipse-workspace/blueridge_visit_database/django/template/loader_tags.py" in render
  97.         return compiled_parent.render(context)
File "/home/tobias/caktus/eclipse-workspace/blueridge_visit_database/django/template/__init__.py" in render
  176.         return self.nodelist.render(context)
File "/home/tobias/caktus/eclipse-workspace/blueridge_visit_database/django/template/__init__.py" in render
  751.                 bits.append(self.render_node(node, context))
File "/home/tobias/caktus/eclipse-workspace/blueridge_visit_database/django/template/debug.py" in render_node
  71.             result = node.render(context)
File "/home/tobias/caktus/eclipse-workspace/blueridge_visit_database/django/template/loader_tags.py" in render
  24.         result = self.nodelist.render(context)
File "/home/tobias/caktus/eclipse-workspace/blueridge_visit_database/django/template/__init__.py" in render
  751.                 bits.append(self.render_node(node, context))
File "/home/tobias/caktus/eclipse-workspace/blueridge_visit_database/django/template/debug.py" in render_node
  71.             result = node.render(context)
File "/home/tobias/caktus/eclipse-workspace/blueridge_visit_database/django/template/loader_tags.py" in render
  24.         result = self.nodelist.render(context)
File "/home/tobias/caktus/eclipse-workspace/blueridge_visit_database/django/template/__init__.py" in render
  751.                 bits.append(self.render_node(node, context))
File "/home/tobias/caktus/eclipse-workspace/blueridge_visit_database/django/template/debug.py" in render_node
  81.             raise wrapped

Exception Type: TemplateSyntaxError at /django-admin/visitdb/site/
Exception Value: Caught an exception while rendering: local variable 'attr' referenced before assignment

Original Traceback (most recent call last):
  File "/home/tobias/caktus/eclipse-workspace/blueridge_visit_database/django/template/debug.py", line 71, in render_node
    result = node.render(context)
  File "/home/tobias/caktus/eclipse-workspace/blueridge_visit_database/django/template/__init__.py", line 898, in render
    dict = func(*args)
  File "/home/tobias/caktus/eclipse-workspace/blueridge_visit_database/django/contrib/admin/templatetags/admin_list.py", line 235, in result_list
    'result_headers': list(result_headers(cl)),
  File "/home/tobias/caktus/eclipse-workspace/blueridge_visit_database/django/contrib/admin/templatetags/admin_list.py", line 110, in result_headers
    admin_order_field = getattr(attr, "admin_order_field", None)
UnboundLocalError: local variable 'attr' referenced before assignment

Change History (5)

comment:1 Changed 7 years ago by Alex

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 7 years ago by Alex

  • milestone set to 1.0 beta

comment:3 Changed 7 years ago by brosner

  • Owner changed from nobody to brosner
  • Status changed from new to assigned

Whoops. Completely missed a couple cases. Thanks for report. Working on it now.

comment:4 Changed 7 years ago by brosner

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [8353]) Fixed #8324 -- Corrected the simple case where list_display is not given. Thanks tobias for the quick report.

comment:5 Changed 4 years ago by jacob

  • milestone 1.0 beta deleted

Milestone 1.0 beta deleted

Note: See TracTickets for help on using tickets.
Back to Top