Opened 16 years ago

Closed 16 years ago

Last modified 13 years ago

#10635 closed (fixed)

list_editable: mention Meta class in ordering exception

Reported by: mkbucc@… Owned by: Jacob
Component: Documentation Version: 1.1-beta
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

>>> l = (opts.ordering or cls.ordering)
>>> l
[ '-id' ]
>>> not l
False
>>>

Following patch fixes this bug.

        To apply:
                $ cd <django-src-root>
                $ patch -p0 < contrib.admin.validate.patch0

        For example, 
                $ cd /usr/lib/python2.5/site-packages/django/
                $ sudo patch -p0 < $OLDPWD/contrib.admin.validate.patch0
                $ cd -


--- /dev/null
+++ ./contrib/admin/validation.py       2009-03-26 10:37:36.000000000 -0400
@@ -67,7 +67,7 @@
     # list_editable
     if hasattr(cls, 'list_editable') and cls.list_editable:
         check_isseq(cls, 'list_editable', cls.list_editable)
-        if not (opts.ordering or cls.ordering):
+        if not len(opts.ordering or cls.ordering):
             raise ImproperlyConfigured("'%s.list_editable' cannot be used "
                 "without a default ordering. Please define ordering on either %s or %s."
                 % (cls.__name__, cls.__name__, model.__name__))

Change History (6)

comment:1 by Alex Gaynor, 16 years ago

Resolution: invalid
Status: newclosed

This looks correct, we want it to evaluate that code only when there isn't an ordering:

[1] >>> not ([] or [])
  [1] : True

[2] >>> not ([] or [''])
  [2] : False

[3] >>> not ([''] or [])
  [3] : False

comment:2 by anonymous, 16 years ago

Component: django.contrib.adminDocumentation
Resolution: invalid
Status: closedreopened
Summary: list_editable: logic error when checking for ordering propertylist_editable: mention Meta class in ordering exception

Reopening, and reassigning to docs with a changed summary.

I had an ordering property on the model object, not the
interior Meta class for the model object. This was what
caused that conditional to fail for me; then I moved the
property to the admin object and somehow thought it was
still failing eh voila, my "patch" worked.

I suggest that the error message explicitly
mention the Meta class; maybe something like this:

Please define ordering on either %s or %s's Meta class.

If I had seen Meta in the message, I would have wondered what
it was, searched the docs, and figured out that on the model
object (unlike the admin object), the ordering property should
be an attribute of the interior Meta class, not the model class
itself.

I think it's worth documenting to draw attention to the
different place this property lives on the admin and
model object.

comment:3 by Jacob, 16 years ago

milestone: 1.1
Triage Stage: UnreviewedAccepted

comment:4 by Jacob, 16 years ago

Owner: changed from nobody to Jacob
Status: reopenedassigned

comment:5 by Jacob, 16 years ago

Resolution: fixed
Status: assignedclosed

(In [10371]) Fixed a whole bunch of small docs typos, errors, and ommissions.

Fixes #8358, #8396, #8724, #9043, #9128, #9247, #9267, #9267, #9375, #9409, #9414, #9416, #9446, #9454, #9464, #9503, #9518, #9533, #9657, #9658, #9683, #9733, #9771, #9835, #9836, #9837, #9897, #9906, #9912, #9945, #9986, #9992, #10055, #10084, #10091, #10145, #10245, #10257, #10309, #10358, #10359, #10424, #10426, #10508, #10531, #10551, #10635, #10637, #10656, #10658, #10690, #10699, #19528.

Thanks to all the respective authors of those tickets.

comment:18 by Jacob, 13 years ago

milestone: 1.1

Milestone 1.1 deleted

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