Proxy model ContentType question

98 views
Skip to first unread message

Ryan

unread,
Feb 17, 2010, 3:05:31 AM2/17/10
to Django users
In django/contrib/contenttypes/models.py (get_for_model), I noticed
that for a proxy model object, the contenttype being returned is of
the base concrete class since it sets opts to the _meta of
proxy_for_model . If one uses a generic relation in the admin app,
you can set the generic contenttype to that of a proxy model class. I
was just wondering if the contenttype get_for_model call is returning
the correct type (concrete base class)?

Ryan

unread,
Feb 19, 2010, 8:36:33 PM2/19/10
to Django users
As an update:

Since you can actually assign a generic relation in the admin app to a
proxy model object, when using a generic relation, the proxy objects
aren't returned because the lookup is using get_for_model which
returns an instance of the base class. (I only figured this out after
having wrapped the ContentType get_by_natural_key call). I'm
wondering what other implications there are if I continue to use the
get_by_natural_key as a way to get the proxy content type.


On Feb 16, 10:05 pm, Ryan <ryanka...@gmail.com> wrote:
> In django/contrib/contenttypes/models.py (get_for_model), I noticed

> that for a proxy model object, thecontenttypebeing returned is of


> the base concrete class since it sets opts to the _meta of
> proxy_for_model .  If one uses a generic relation in the admin app,

> you can set the genericcontenttypeto that of a proxy model class.  I
> was just wondering if thecontenttypeget_for_model call is returning

Reply all
Reply to author
Forward
0 new messages