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 2
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_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')), ], 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.
Edit:
Under Django 1.8 makemigrations does not create a migration, while in Django 1.11 it creates one.
Change History (2)
comment:1 by , 7 years ago
Description: | modified (diff) |
---|
comment:2 by , 7 years ago
Description: | modified (diff) |
---|