#25122: GenericRelation with a string argument will raise an AttributeError when
accessed.
-------------------------------------+-------------------------------------
Reporter: martin-c | Owner: nobody
Type: Bug | Status: new
Component: | Version: 1.8
contrib.contenttypes | Keywords: GenericRelation,
Severity: Normal | AttributeError
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
In other relationship fields it is possible to specify the target model by
passing its model name as a string, such as
{{{
#!python
class Car(models.Model):
manufacturer = models.ForeignKey('production.Manufacturer')
}}}
However, in the case of a GenericRelation,
{{{
#!python
class Car(models.Model):
manufacturers = GenericRelation('production.Manufacturer')
}}}
accessing the manufacturers field will cause a AttributeError to be
raised.
{{{
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/Users/.../.python-env/lib/python2.7/site-
packages/django/contrib/contenttypes/fields.py", line 406, in __get__
superclass = rel_model._default_manager.__class__
AttributeError: 'unicode' object has no attribute '_default_manager'
}}}
So it seems only the target class instance can be passed to
GenericRelation().
--
Ticket URL: <https://code.djangoproject.com/ticket/25122>
Django <https://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 unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/051.02b5752302727c52d5d35fc8b6c6a15c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.