简体   繁体   English

Django中的Python社交认证,makemigrations检测不到任何变化

[英]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 我正在按照文档在我的django项目上获取python社会认证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: 'social.apps.django_app.default',添加到我的settings.py中的INSTALLED_APPS之后我运行:

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. 因为没有这个,我无法迁移以创建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 其中'main'是我的应用程序的名称

Today i ran into this problem. 今天我遇到了这个问题。 The error is in the documentation itself. 错误在文档本身。

You should run $ python manage.py migrate directly. 你应该直接运行$ python manage.py migrate It creates tables in the database. 它在数据库中创建表。

All the old tutorials used makemigrations , I think it was used in earlier versions of django. 所有旧的教程都使用makemigrations ,我认为它是在早期版本的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). 让我在最新版本的Django中清楚一些关于迁移的基本术语(从1.7到开发版)。

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中,One必须在模型中进行更改(最终在数据库中),然后One必须使用South应用程序在数据库中应用更改而不影响旧数据库。

Django developer community has included this south app in and after Django 1.7 and also provided some simple commands to apply migrations. Django开发者社区在Django 1.7中和之后都包含了这个南方应用程序,并提供了一些简单的命令来应用迁移。

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. 或者如果它是初始的,则无需指定app_name,它将考虑所有应用程序。

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. 或者如果是初始,则无需指定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. 如果您有任何问题,请拍摄任何问题,请查看Django 关于迁移的官方文档以获取更多信息。

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. 在您的urls.py添加网址,将其链接到“社交”网址。

到Django <1.8

INSTALLED_APPS ['social.apps.Django_appConfig',]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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