#10635 closed (fixed)
list_editable: mention Meta class in ordering exception
Reported by: | 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 , 16 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:2 by , 16 years ago
Component: | django.contrib.admin → Documentation |
---|---|
Resolution: | invalid |
Status: | closed → reopened |
Summary: | list_editable: logic error when checking for ordering property → list_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 , 16 years ago
milestone: | → 1.1 |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:4 by , 16 years ago
Owner: | changed from | to
---|---|
Status: | reopened → assigned |
comment:5 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
(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.
This looks correct, we want it to evaluate that code only when there isn't an ordering: