#27709: ContentTypes.objects.get_for_models returns inconsistent results for 
proxy
models
--------------------------------------+------------------------------------
     Reporter:  Peter Inglesby        |                    Owner:  nobody
         Type:  Bug                   |                   Status:  new
    Component:  contrib.contenttypes  |                  Version:  master
     Severity:  Normal                |               Resolution:
     Keywords:                        |             Triage Stage:  Accepted
    Has patch:  0                     |      Needs documentation:  0
  Needs tests:  0                     |  Patch needs improvement:  0
Easy pickings:  0                     |                    UI/UX:  0
--------------------------------------+------------------------------------
Changes (by Simon Charette):

 * version:  1.10 => master
 * type:  Uncategorized => Bug
 * stage:  Unreviewed => Accepted


Comment:

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

 The proxy model should only be returned as a key if
 
[https://docs.djangoproject.com/en/1.10/ref/contrib/contenttypes/#django.contrib.contenttypes.models.ContentTypeManager.get_for_models
 for_concrete_models=False] is specified.

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

 A single one changing
 
[https://github.com/django/django/blob/ed8c0c941df0f321fb5751db572a9ec773d5118a/django/contrib/contenttypes/models.py#L83
 this line] to `results[opts.concrete_model if for_concrete_models else
 model] = ct` and adding tests to
 
[https://github.com/django/django/blob/ed8c0c941df0f321fb5751db572a9ec773d5118a/tests/contenttypes_tests/test_models.py
 this module should do].

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

Reply via email to