#23822: Serialize model managers in migrations
-----------------------------+------------------------------------
Reporter: MarkusH | Owner: MarkusH
Type: New feature | Status: new
Component: Migrations | Version: master
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
-----------------------------+------------------------------------
Comment (by MarkusH):
Hi Shai,
the managers will be serialized in the same way as e.g. functions for
field arguments are serialized: imported and referenced. A migration for a
custom user model will thus look like
{{{#!python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import myapp.models
class Migration(migrations.Migration):
operations = [
migrations.CreateModel(
name='MyUser',
fields=[
('id', models.AutoField(verbose_name='ID',
serialize=False, auto_created=True, primary_key=True)),
('password', models.CharField(max_length=128,
verbose_name='password')),
('email', models.EmailField(max_length=255,
verbose_name='email address', blank=True, unique=True)),
],
options={
'verbose_name': 'user',
'verbose_name_plural': 'users',
},
managers=[
('objects', myapp.models.MyUserManager()),
],
),
]
}}}
The `managers` argument keeps track of all managers of a model unless only
the default manager (`objects = models.Manager()`) is available. The
argument will be empty / not given in those situations.
A current work-in-progress implementation is available in my
[https://github.com/MarkusH/django/compare/migration-managers migration-
managers] branch.
--
Ticket URL: <https://code.djangoproject.com/ticket/23822#comment:3>
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/065.0c3f807cf89fcc7364df0119a5d4a7b6%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.