order_with_respect_to fail any workaround ?

12 views
Skip to first unread message

Thierry Stiegler

unread,
Dec 6, 2008, 3:34:47 AM12/6/08
to Django users
Hello,

I got some errors by using the Meta options order_with_respect_to:
<code>
class Category(PublicationBase, LocalisationBase):
ITEM_PER_PAGE = 12
name = models.CharField(max_length=255)
pictogram = models.ImageField(upload_to="categories", blank=True)
old_id = models.PositiveIntegerField(blank=True)
parent = models.ForeignKey("Category", blank=True, null=True)

class Meta:
ordering = ['name']
order_with_respect_to = 'parent'


def __unicode__(self):
return self.name
</code>

An I got this error :
<code>
Validating models...
Unhandled exception in thread started by <function inner_run at
0x010ABBF0>
Traceback (most recent call last):
File "C:\Python25\django-trunk\django\core\management\commands
\runserver.py", line 48, in inner_run
self.validate(display_num_errors=True)
File "C:\Python25\django-trunk\django\core\management\base.py", line
249, in validate
num_errors = get_validation_errors(s, app)
File "C:\Python25\django-trunk\django\core\management
\validation.py", line 28, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "C:\Python25\django-trunk\django\db\models\loading.py", line
128, in get_app_errors
self._populate()
File "C:\Python25\django-trunk\django\db\models\loading.py", line
57, in _populate
self.load_app(app_name, True)
File "C:\Python25\django-trunk\django\db\models\loading.py", line
72, in load_app
mod = __import__(app_name, {}, {}, ['models'])
File "C:\www\zebest-3000.com\trunk\zebest3000\..\apps\messages
\models.py", line 113, in <module>
notification = get_app('notification')
File "C:\Python25\django-trunk\django\db\models\loading.py", line
111, in get_app
self._populate()
File "C:\Python25\django-trunk\django\db\models\loading.py", line
57, in _populate
self.load_app(app_name, True)
File "C:\Python25\django-trunk\django\db\models\loading.py", line
72, in load_app
mod = __import__(app_name, {}, {}, ['models'])
File "C:\www\zebest-3000.com\trunk\zebest3000\..\apps\portail
\models.py", line 50, in <module>
class Category(PublicationBase, LocalisationBase):
File "C:\Python25\django-trunk\django\db\models\base.py", line 153,
in __new__
new_class._prepare()
File "C:\Python25\django-trunk\django\db\models\base.py", line 178,
in _prepare
setattr(opts.order_with_respect_to.rel.to, 'get_%s_order' %
cls.__name__.lower(), curry(method_get_order, cls))
AttributeError: 'str' object has no attribute 'get_category_order'
</code>

I found this ticket (http://code.djangoproject.com/ticket/2740), but I
don"t want to patch django. Any Idea for a workaround ?


Thierry Stiegler

unread,
Dec 6, 2008, 4:49:46 AM12/6/08
to Django users
Juste for precision I use the trunk.

On Dec 6, 9:34 am, Thierry Stiegler <thierry.stieg...@gmail.com>
wrote:

Thierry Stiegler

unread,
Dec 23, 2008, 10:34:35 AM12/23/08
to Django users
I answer django developpers (http://groups.google.com/group/django-
developers/t/280bca5001faca07) so wait and see.

On 6 déc, 09:34, Thierry Stiegler <thierry.stieg...@gmail.com> wrote:
> Hello,
>
> I got some errors by using the Meta optionsorder_with_respect_to:
> <code>
> class Category(PublicationBase, LocalisationBase):
>     ITEM_PER_PAGE = 12
>     name = models.CharField(max_length=255)
>     pictogram = models.ImageField(upload_to="categories", blank=True)
>     old_id = models.PositiveIntegerField(blank=True)
>     parent = models.ForeignKey("Category", blank=True, null=True)
>
>     class Meta:
>         ordering = ['name']
>        order_with_respect_to= 'parent'
Reply all
Reply to author
Forward
0 new messages