Opened 14 years ago

Closed 14 years ago

Last modified 12 years ago

#187 closed defect (fixed)

Uknown error with ordering in the admin interface

Reported by: Moof <moof@…> Owned by: Adrian Holovaty
Component: contrib.admin Version: 1.0
Severity: normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I've defined the following model:

class Blog(meta.Model):
    fields = (
        meta.OneToOneField(Site), #One blog per site
        meta.CharField('name', maxlength=100, help_text="Blog Title, as shown on the page"),
        meta.CharField('subtitle', maxlength=500),
        meta.CharField('titlebarname', "Title Bar Name", maxlength=50, blank=True,
                       help_text="Short name for putting in <title> elements")
    admin = meta.Admin()

    def __repr__(self):

When I try to list my blogs by going to http://localhost:8000/admin/blog/blogs/ I always end up with the following error:

There's been an error:

Traceback (most recent call last):

  File "D:\My Documents\Python Sources\Django\django\core\handlers\", line 63, in get_response
    return callback(request, **param_dict)

  File "D:\My Documents\Python Sources\Django\django\views\admin\", line 97, in change_list
    ordering = lookup_opts.admin.ordering or lookup_opts.ordering or ['-' +]

AttributeError: 'NoneType' object has no attribute 'ordering'

A quick play with the object in the interpreter shows it's working correctly:

>>> from import *
>>> b = blogs.get_list()
>>> b
[My Blog]
>>> from import *
>>> bs = blogs.get_list()
>>> bs
[My Blog]
>>> b = bs[0]
>>> b
My Blog
'My Blog'
>>> b.subtitle
'Where you find all the news'
>>> b.titlebarname
' '
>>> s = b.get_site()
>>> s
>>> s.domain
'My Django site'

Change History (3)

comment:1 Changed 14 years ago by Clint Ecker <clintecker@…>

Please remember that the Trac site isn't for support. Please use the discussion lists: or #django on

comment:2 Changed 14 years ago by Jacob

Clint: this is a bug, and is the right place to file it.

comment:3 Changed 14 years ago by Adrian Holovaty

Resolution: fixed
Status: newclosed

(In [331]) Fixed #187 -- Made admin view handle one-to-one relationships in which the parent relationship doesn't have the 'admin' parameter set. Thanks, Moof

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