#27709: ContentTypes.objects.get_for_models returns inconsistent results for 
proxy
models
------------------------------------------------+------------------------
               Reporter:  Peter Inglesby        |          Owner:  nobody
                   Type:  Uncategorized         |         Status:  new
              Component:  contrib.contenttypes  |        Version:  1.10
               Severity:  Normal                |       Keywords:
           Triage Stage:  Unreviewed            |      Has patch:  0
    Needs documentation:  0                     |    Needs tests:  0
Patch needs improvement:  0                     |  Easy pickings:  0
                  UI/UX:  0                     |
------------------------------------------------+------------------------
 If `UserProxy` is a proxy model, then the result of calling
 `ContentTypes.objects.get_for_models(UserProxy)` depends on whether the
 content types cache is empty:

 {{{
 >>> ContentType.objects.clear_cache()
 >>> ContentType.objects.get_for_models(UserProxy)
 {<class 'django.contrib.auth.models.User'>: <ContentType: user>}
 >>> ContentType.objects.get_for_models(UserProxy)
 {<class 'gallery.models.UserProxy'>: <ContentType: user>}
 }}}

 In particular, on the first call to `get_for_models`, the key in the
 results dictionary is the concrete model, while on subsequent calls it is
 the proxy model.

 I believe the correct behaviour is to return the proxy model as the key.

 I have two proposed fixes, each with pros and cons.  Should I open two
 separate pull requests?

--
Ticket URL: <https://code.djangoproject.com/ticket/27709>
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/050.087ea8023f0b20bbb465fc9b5f2370b1%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to