简体   繁体   中英

Python social auth in Django, makemigrations detects no changes

I was following the documentation to get python social auth on my django project https://python-social-auth.readthedocs.org/en/latest/configuration/django.html

And after adding 'social.apps.django_app.default', to the INSTALLED_APPS in my settings.py I run this:

python manage.py makemigrations

I get this

No changes detected

Shouldn't this command be doing something. Because without this I can't migrate to create the tables that are needed for the auth.

EDIT:

I've also tried this command, and still ended up getting the same result

python manage.py makemigrations main

where 'main' is the name of my app

Today i ran into this problem. The error is in the documentation itself.

You should run $ python manage.py migrate directly. It creates tables in the database.

All the old tutorials used makemigrations , I think it was used in earlier versions of django.

My answer will be cover some basics so one can understand this types of errors easily.

Let me clear some basic terminology about migrations in the latest versions of Django(From 1.7 to under development ones).

In older versions of Django when One has to make changes in Models (Eventually in Database) then One has to use South app to apply changes in Database without affecting older database.

Django developer community has included this south app in and after Django 1.7 and also provided some simple commands to apply migrations.

When one install New app(Above question scenario) or one make changes in existing models and wish to apply changes in database then one has to tell database about what changes they want to make. To do so one has to make migrations and below is the command.

$ python manage.py makemigrations app_name

or If it is initial then no need to specify app_name, it will consider all apps.

This command will generate migrations files which will include instructions for database to make what tables and what are the attributes of that table and what will be the relationships between tables and what are changes in the current tables etc etc.

Now one has to run below command to apply this all changes in database.

$ python manage.py migrate app_name

or If it is initial then no need to specify app_name.

Please shoot any questions If you have any and please take a look at Django's official documentation on migrations for more information.

The possible reason is your project doesn't use any database models of 'social' application yet. Add a URL in your urls.py , link it to 'social' urls.

到Django <1.8

INSTALLED_APPS ['social.apps.Django_appConfig',]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM