Created
November 27, 2014 16:54
-
-
Save MarkusH/d84618db929fd6fcdb9f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# showmigrations comes from https://github.com/MarkusH/django/tree/ticket23359-2 | |
$ python manage.py showmigrations --plan -v 2 | |
[X] contenttypes.0001_initial | |
[X] auth.0001_initial ... (contenttypes.0001_initial) | |
[X] admin.0001_initial ... (auth.0001_initial, contenttypes.0001_initial) | |
[X] auth.0002_alter_permission_name_max_length ... (auth.0001_initial) | |
[X] auth.0003_alter_user_email_max_length ... (auth.0002_alter_permission_name_max_length) | |
[X] auth.0004_alter_user_username_opts ... (auth.0003_alter_user_email_max_length) | |
[X] auth.0005_alter_user_last_login_null ... (auth.0004_alter_user_username_opts) | |
[X] sites.0001_initial | |
[X] flatpages.0001_initial ... (sites.0001_initial) | |
[X] otherapp.0001_initial | |
[X] testapp.0001_initial ... (auth.0001_initial, otherapp.0001_initial) | |
[X] otherapp.0002_auto_20141127_1753 ... (auth.0001_initial, testapp.0001_initial, otherapp.0001_initial) | |
[X] redirects.0001_initial ... (sites.0001_initial) | |
[X] sessions.0001_initial |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from __future__ import unicode_literals | |
from django.db import models, migrations | |
class Migration(migrations.Migration): | |
dependencies = [ | |
] | |
operations = [ | |
migrations.CreateModel( | |
name='ThroughModel', | |
fields=[ | |
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), | |
], | |
options=None, | |
bases=None, | |
), | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from __future__ import unicode_literals | |
from django.db import models, migrations | |
from django.conf import settings | |
class Migration(migrations.Migration): | |
dependencies = [ | |
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | |
('testapp', '0001_initial'), | |
('otherapp', '0001_initial'), | |
] | |
operations = [ | |
migrations.AddField( | |
model_name='throughmodel', | |
name='foo', | |
field=models.ForeignKey(to='testapp.Foo'), | |
preserve_default=True, | |
), | |
migrations.AddField( | |
model_name='throughmodel', | |
name='user', | |
field=models.ForeignKey(to=settings.AUTH_USER_MODEL), | |
preserve_default=True, | |
), | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
# Create your models here. | |
class ThroughModel(models.Model): | |
foo = models.ForeignKey('testapp.Foo') | |
user = models.ForeignKey('auth.User') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from __future__ import unicode_literals | |
from django.db import models, migrations | |
from django.conf import settings | |
class Migration(migrations.Migration): | |
dependencies = [ | |
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | |
('otherapp', '0001_initial'), | |
] | |
operations = [ | |
migrations.CreateModel( | |
name='Foo', | |
fields=[ | |
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), | |
('users', models.ManyToManyField(through='otherapp.ThroughModel', to=settings.AUTH_USER_MODEL)), | |
], | |
options=None, | |
bases=None, | |
), | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
class Foo(models.Model): | |
users = models.ManyToManyField('auth.User', through='otherapp.ThroughModel') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment