Code

Opened 5 years ago

Closed 5 years ago

Last modified 3 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: UI/UX:

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__))

Attachments (0)

Change History (6)

comment:1 Changed 5 years ago by Alex

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

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 Changed 5 years ago by anonymous

  • Component changed from django.contrib.admin to Documentation
  • Resolution invalid deleted
  • Status changed from closed to reopened
  • Summary changed from list_editable: logic error when checking for ordering property to 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 Changed 5 years ago by jacob

  • milestone set to 1.1
  • Triage Stage changed from Unreviewed to Accepted

comment:4 Changed 5 years ago by jacob

  • Owner changed from nobody to jacob
  • Status changed from reopened to assigned

comment:5 Changed 5 years ago by jacob

  • Resolution set to fixed
  • Status changed from assigned to 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.

comment:18 Changed 3 years ago by jacob

  • milestone 1.1 deleted

Milestone 1.1 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.