Opened 19 years ago

Closed 19 years ago

Last modified 17 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

Description

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):
        return self.name

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\base.py", line 63, in get_response
    return callback(request, **param_dict)

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

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

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

>>> from django.models.blog import *
>>> b = blogs.get_list()
>>> b
[My Blog]
>>> from django.models.blog import *
>>> bs = blogs.get_list()
>>> bs
[My Blog]
>>> b = bs[0]
>>> b
My Blog
>>> b.name
'My Blog'
>>> b.id
1
>>> b.subtitle
'Where you find all the news'
>>> b.titlebarname
' '
>>> s = b.get_site()
>>> s
mysite.com
>>> s.domain
'mysite.com'
>>> s.name
'My Django site'
>>> 

Change History (3)

comment:1 by Clint Ecker <clintecker@…>, 19 years ago

Please remember that the Trac site isn't for support. Please use the discussion lists: http://groups-beta.google.com/group/django-users or #django on irc.freenode.net

comment:2 by Jacob, 19 years ago

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

comment:3 by Adrian Holovaty, 19 years ago

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