#23444: Legacy code unnecessarily creates ContentType object for `through` model
when using it in inlines
--------------------------------------+------------------------------------
     Reporter:  a1tus                 |                    Owner:  nobody
         Type:  Cleanup/optimization  |                   Status:  new
    Component:  contrib.admin         |                  Version:  master
     Severity:  Normal                |               Resolution:
     Keywords:                        |             Triage Stage:  Accepted
    Has patch:  1                     |      Needs documentation:  0
  Needs tests:  0                     |  Patch needs improvement:  0
Easy pickings:  0                     |                    UI/UX:  0
--------------------------------------+------------------------------------

Comment (by a1tus):

 Moving it to `get_for_model` might be logical. I've checked some details
 to be sure.

 At the moment syncdb/migrate creates CT objects here:
 
https://github.com/django/django/blob/master/django%2Fcontrib%2Fcontenttypes%2Fmanagement.py

 So it just calls `app_config.get_models()` and then creates corresponding
 objects.
 Those app CT objects that were not found are suggested to be deleted.

 Moving on to `get_models.__doc__`:
 {{{
 Returns a list of all installed models.

 By default, the following models aren't included:

 - auto-created models for many-to-many relations without
   an explicit intermediate table,
 - models created to satisfy deferred attribute queries,
 - models that have been swapped out.
 }}}

 So may be some other checks in addition to "being a `through` model"
 should be added there.

 And one more thing. I doesn't make much sense but some users could use
 their `through` model in admin not only in inlines and therefore they
 might need its CT object. So that change can affect them in some way.

--
Ticket URL: <https://code.djangoproject.com/ticket/23444#comment:9>
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/063.e4f8e769ba5a76f3fefe0ca62d87e6ff%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to