#32833: ContentType.objects.get_for_models() in migrations does not works for
multiple models
-------------------------------------+-------------------------------------
     Reporter:  Heraldo Lucena       |                    Owner:  Heraldo
                                     |  Lucena
         Type:  Bug                  |                   Status:  assigned
    Component:                       |                  Version:  3.1
  contrib.contenttypes               |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  1
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Keryn Knight):

 Replying to [comment:4 Heraldo Lucena]:
 > I tried to reproduce this problem but I could not [...]

 My guess would be that the ContentTypeManager instance already had a
 partially filled (or empty) cache when you encountered the error, such
 that `self._get_from_cache(modelinstance._meta)` worked (didn't throw a
 `KeyError` looking in the `self._cache`).

 - If you pass in 2 model classes `Group` and `User` and ''both'' are
 already in its internal cache, then `needed_opts` is empty and
 `needed_opts.pop(ct.model_class()._meta, [])` doesn't occur.
 - If you pass the same 2 classes and only 1 or 0 of them are in the
 `self._cache` already, you'd fill the missing items into `needed_opts` and
 hit the line which has caused you problems.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32833#comment:6>
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.1163c90e68ca61b48a79b75801b3ffa5%40djangoproject.com.

Reply via email to