#13241: order_with_respect_to fails on a relationship on a model that has not
yet
been defined
------------------------------------------+---------------------------------
Reporter: Goldan | Owner: nobody
Status: new | Milestone:
Component: Database layer (models, ORM) | Version: SVN
Keywords: order_with_respect_to | Stage: Unreviewed
Has_patch: 0 |
------------------------------------------+---------------------------------
If I specify 'order_with_respect_to' on a field linked to a model that
hasn't been defined yet, I get the following error:
<...>File "/usr/lib/python2.6/dist-packages/django/db/models/base.py",
line 223, 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_location_order'
When I swap declarations of Location and City models, the error
disappears.
Here is the code:
class Location(TimeStampedModel):
'''Single location on a map, e.g. building.'''
address = models.CharField(u"адрес", max_length=75, help_text=u"Улица,
корпус, дом")
city = models.ForeignKey('City', related_name="locations",
verbose_name=u"город")
metro_stations = models.ManyToManyField('MetroStation',
related_name="locations", verbose_name=u"ближайшие станции метро",
blank=True, null=True)
class Meta:
verbose_name = u"адрес"
verbose_name_plural = u"адреса"
order_with_respect_to = 'city'
class City(TimeStampedModel):
'''A city.'''
name = models.CharField(u"название", max_length=30)
class Meta:
verbose_name = u"город"
verbose_name_plural = u"города"
--
Ticket URL: <http://code.djangoproject.com/ticket/13241>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.