#32833: ContentType.objects.get_for_models() in migrations does not works for
multiple models
--------------------------------------+------------------------------------
Reporter: Heraldo Lucena | Owner: nobody
Type: Bug | Status: new
Component: contrib.contenttypes | Version: 3.1
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):
* stage: Unreviewed => Accepted
Comment:
Since `ContentTypeManager` is marked as `use_in_migrations = True` it
should be able to handle this case.
There's two possible solutions here:
1. Create an `AbstractContentType(models.Model)` abstract model class that
include most of the logic `ContentType` and have the latter subclass the
former. From there `CreateModel(bases)`
[https://github.com/django/django/blob/ed3af3ff4b3cfb72de598f1b39a1028ba3826efb/django/contrib/contenttypes/migrations/0001_initial.py#L25
should be adjusted to pass this base instead].
2. Adjust `ContentTypeManager.get_for_models` to avoid calling
`.model_class()` and inline its logic in the manager method instead.
Feels like 2. is the less disruptive approach and easier to test. Would
you be interested in writing a patch PR for it?
--
Ticket URL: <https://code.djangoproject.com/ticket/32833#comment:2>
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.86cb1ae1fa3a56c427d6ea68dcb3c658%40djangoproject.com.