-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
django 1.7 migrations changes detected for socialaccount and socialapps #749
Comments
Django recognizes changes in the |
While indeed somewhat unexpected, the ticket referred by @yourcelf clearly states this is "by design". |
SocialAccount instances will rarely be created by hand, usually created by allauth directly. I would say removing the choices all together is probably the solution for this one, since there is little benefit of having the choices there in the first place, but the fact that it is dynamic causes issues with migrations (which is a gotcha that will get everyone). |
The temporary solution I did while this is being figured out is creating my own migrations for socialaccount by adding this to the settings file: MIGRATION_MODULES = {
'socialaccount': 'socialaccount_overrides.migrations',
} |
The last comment on https://code.djangoproject.com/ticket/22837 links to issue https://code.djangoproject.com/ticket/13181 which added support for passing a callable to diff --git a/allauth/socialaccount/models.py b/allauth/socialaccount/models.py
index 08be06b..5352afd 100644
--- a/allauth/socialaccount/models.py
+++ b/allauth/socialaccount/models.py
@@ -37,7 +37,7 @@ class SocialApp(models.Model):
provider = models.CharField(verbose_name=_('provider'),
max_length=30,
- choices=providers.registry.as_choices())
+ choices=providers.registry.as_choices)
name = models.CharField(verbose_name=_('name'),
max_length=40)
client_id = models.CharField(verbose_name=_('client id'), However, https://code.djangoproject.com/ticket/13181 is going into Django 1.8, and I can't tell if it will be backported to Django 1.7. |
Any updates on this? I am seeing the same in Django 3.1. @pennersr |
The same explanation for how to avoid this seems also to be given here: http://tech.yunojuno.com/pro-tip-django-choices-and-migrations . |
Came here because something caused changes in Only things I did with auth — installed django-sesame and unregistered
# account/migrations
class Migration(migrations.Migration):
dependencies = [
('account', '0002_email_max_length'),
]
operations = [
migrations.AlterField(
model_name='emailaddress',
name='id',
field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
),
migrations.AlterField(
model_name='emailconfirmation',
name='id',
field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
),
]
# socialaccount/migrations
class Migration(migrations.Migration):
dependencies = [
('socialaccount', '0003_extra_data_default_dict'),
]
operations = [
migrations.AlterField(
model_name='socialaccount',
name='id',
field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
),
migrations.AlterField(
model_name='socialapp',
name='id',
field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
),
migrations.AlterField(
model_name='socialtoken',
name='id',
field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
),
] update:
class CustomUser(AbstractUser):
pass Update:
Addressed in #2829 PR |
When you run
python manage.py migrate
a second time, it says that there are changes.Running
python manage.py makemigrations
, the changes are actually for the socialaccount and socialapp apps.The migration file is written into the site-packages directory:
/venv/lib/python2.7/site-packages/allauth/socialaccount/migrations/0002_auto_20141022_1 424.py
I saw in the code that the changes are about the providers. The change will be detected everytime the list of providers change.https://github.com/pennersr/django-allauth/blob/master/allauth/socialaccount/migrations/0001_initial.py#L21
Is that normal?
Thanks
Here is the migration file generated
The text was updated successfully, but these errors were encountered: