【问题标题】:South migration for social auth南移社会权威
【发布时间】:2014-04-21 10:28:04
【问题描述】:

我在我的 django 项目中使用南。我刚刚在settings.py中添加了social_auth,当我运行这个命令时: python manage.py schemamigration social_auth --auto

它说:似乎什么都没有改变。

请告诉我如何为社交身份验证创建表,因为通过此命令不会创建表。

【问题讨论】:

  • 你真的验证过这些表还不存在吗?
  • 是的,我验证了它..但它现在正在工作..通过评论中提到的命令。 python manage.py migrate social_auth

标签: django django-south django-socialauth


【解决方案1】:

django-social-auth 工作完美,除了它需要 South 并且它不适用于较新版本的 Django。

要在 django-social-auth 中移除 South 的依赖关系,只需移除 South 创建的迁移,然后使用 Django 1.7 中更新的迁移引擎创建新迁移 >。

这就是我修复它的方法:

# Install django (if you haven't) and django-social-auth
(my_venv)$ pip install django django-social-auth

# Delete the South migrations
# Using a virtual environment: my_venv
# In case you use python3, replace
(my_venv)$ rm <path_to_my_venv>/lib/python2.7/site-packages/social_auth/migrations/000*

# Create an dummy django project
(my_venv)$ django-admin startproject asdf

将 django-social-auth 添加到 asdf/settings.py 文件中

### asdf/asdf/settings.py
...
INSTALLED_APPS = (
    ...
    'social_auth',
)
...

最后为 django-social-auth 创建新的迁移

# Create new migrations
$ python asdf/manage.py makemigrations social_auth

# Delete the dummy django-project
$ rm -r asdf

此修复适用于在同一虚拟环境下工作的所有 Django 项目。

【讨论】:

  • 这使用 django 1.8 为我修复了它。谢谢。
  • 太棒了,这对我有用!我在此处添加了对您建议的解决方案的引用 (code.djangoproject.com/ticket/24524#comment:20)。
  • django-social-auth 不再维护,它已被 python-social-auth link 取代。根据您的情况,从一个平台迁移到另一个平台相对简单,强烈推荐 :)
【解决方案2】:

我认为您不需要为 social_auth 生成迁移,因为这个应用应该已经有了它的迁移。相反,您需要执行它们,因此在您的设置中添加“social_auth”后,您只需运行以下命令:

python manage.py migrate social_auth

【讨论】:

    猜你喜欢
    • 2010-11-13
    • 2010-10-08
    • 2016-02-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-09
    • 1970-01-01
    相关资源
    最近更新 更多