Opened 7 years ago
Last modified 7 years ago
#28920 closed Bug
AlterModelManagers migration is generated for all Models with custom Managers, which is not compatible with Django 1.8 — at Version 1
Reported by: | Michał Bońkowski | Owned by: | nobody |
---|---|---|---|
Component: | Migrations | Version: | 1.11 |
Severity: | Normal | Keywords: | |
Cc: | Sjoerd Job Postmus | Triage Stage: | Unreviewed |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
We have a Model and a default_manager
with a custom name:
class MyModel(models.Model): my_field = models.BooleanField() my_objects = models.Manager()
This creates a migration with a default manager though no manager is marked with use_in_migrations = True.
class Migration(migrations.Migration): operations = [ migrations.CreateModel( name='MyModel', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('my_field', models.BooleanField()), ], options={ 'default_manager_name': 'my_objects', }, managers=[ ('my_objects', django.db.models.manager.Manager()), ], ), ]
According to https://code.djangoproject.com/ticket/26643#comment:5, we should not get this manager added to the state.
After some investigation, we can see that manager with any other name than objects
will be added to the migration: https://github.com/django/django/blob/1.11.8/django/db/migrations/state.py#L537.
Note:
See TracTickets
for help on using tickets.