-
-
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
Migrations are added when social account providers are added or removed #2652
Comments
What version of allauth? Do you have any allauth based settings set? |
django-allauth==0.41.0
|
Have you tried reinstalling django-allauth? I wonder if a migration was made accidentally at some point and now its causing the trigger. Essentially you should only have these exact four files in the socialaccount migrations. |
Hey @iarp That is true. I have those four files. But Django notifies me that something is missing and when I run As for reinstalling: The problem is I am on a big project where there are many installations running on other machines run by other devs and servers and such. I cannot just uninstall and reinstall on all these other machines as I don't control them. As far as I can tell, the problem is that the way the model is written and also the migration, means that the list of providers will be taken by executing To be entirely honest, I also use django allauth on a different project where I have changed the list of providers over time, and it has for some reason not caused any migrations to be created. I cannot figure out why that is. |
What version of python? You can't just remove the brackets because django requires choices to be an iterable and not a callable. |
Python 3.8.3. The change I am making is that previously none of the socialaccount providers were enabled. Now Google is enabled. So the migration Django wants to autocreate looks like this:
That seems to be entirely reasonable. |
Ah I see. My bad. I wonder if storing this in the model is the right place then. Maybe it would be better to enforce it at the level of the form that is being shown on the admin page? If you run a site for several years, I think it's fairly common that your list of connected social sites will change over time. Some sites close down, others are getting more important, some change focus, etc. . So it's probably not a good idea to have to lock in on a list right at the beginning of starting a site ro system of sites, right? I am wondering what others have been doing to avoid this problem. |
That's the thing though, there is no locked in list. Since allauth uses If you're up to it you could zip up your allauth folder and share it, i'll look it over and see if i can see anything. Beyond that though I'm not sure. I matched every version of django, allauth, and python that you supplied and i can add/remove providers at will and makemigrations never has a problem. |
I see. Maybe there have been some changes in how Django does that? Or maybe some changes per database? I am using postgresql, if that makes a difference. I have seen the issue has come up before [1], so maybe relying on it not actually storing the choices anywhere doesn't work under some specific setups?
I don't have a special allauth folder that is different from what you people distribute. I just install allauth using:
So it tries to create a migration file in that place: [1] #749 |
Migrations do not depend on the database, they are based on the existing migration files and the current models. The model and the initial migration are based on Somehow either one of two things has happened:
There is also a possibility of some sort of obscure issue is changing how providers are being loaded between model initialization and migration checks. For instance if I put |
Ah, thanks! I found it. The iwas apparently that I changed the name of the Google Provider in the top level urls.py file:
This change was then not applied during the initial migration but was applied when checking the model. I have entirely removed this now and just put it in the template instead. Thanks so much, @iarp for helping with this! |
Out of curiosity how did you find that as being the issue ? |
I added the print line you mentioned and the output was:
|
Hey,
using Django 3.1, when I add or remove an entry like
in
INSTALLED_APPS
, Django notifies me that I need to run./manage.py makemigrations
and then creates migrations inside of the socialaccount app. The reason for this seems to be that the way the model is written, the list of possible choices is calculated rather than handing over a callable.This:
Rather than:
I see this has been an issue for a long time and some seem to be able to get around it, but I haven't been able to figure out exactly how they do it.
Any idea why it's like this and what is the best workaround?
The text was updated successfully, but these errors were encountered: