简体   繁体   English

Django 1.7 - 应用“your_app_name”没有迁移

[英]Django 1.7 - App 'your_app_name' does not have migrations

I am trying to upgrade from Django 1.6.7 to Django 1.7.1, so I have been trying to migrate my app.我正在尝试从 Django 1.6.7 升级到 Django 1.7.1,所以我一直在尝试迁移我的应用程序。

I have followed the django docs here .我在这里关注了 django 文档

I deleted the south from my installed apps.我从我安装的应用程序中删除了南方。

In the migration directory, I delete the numbered migration files and the.pyc files but I kept the directory & __ init__.py file.在迁移目录中,我删除了编号的迁移文件和 .pyc 文件,但我保留了目录 & __ init__.py 文件。

I then run:然后我运行:

python manage.py makemigrations your_app_name

I receive the following confirmation message:我收到以下确认信息:

Migrations for 'your_app_name':
  0001_initial.py:
    - Create model UserProfile

Next I run:接下来我运行:

python manage.py migrate your_app_name

I received the following error:我收到以下错误:

CommandError: App 'your_app_name' does not have migrations (you cannot selectively sync unmigrated apps)

As per the docs, I also ran:根据文档,我还运行了:

python manage.py migrate --fake your_app_name

I received the same error message:我收到了同样的错误信息:

CommandError: App 'your_app_name' does not have migrations (you cannot selectively sync unmigrated apps)

Can anyone shed some light on why this will not work for me?谁能阐明为什么这对我不起作用?

I noticed that only those apps that actually contain a migrations folder that contain a file __init__.py are recognized by migrations.我注意到只有那些实际包含一个包含文件__init__.pymigrations文件夹的应用程序才能被迁移识别。 IE having only models.py in your app is not enough. IE 在您的应用程序中只有 models.py 是不够的。

If you have a single app, running migrate without specifying the app or migration may work.如果您只有一个应用程序,则在不指定应用程序或迁移的情况下运行migrate可能会起作用。

If so, the first thing to check is that your app name matched that specified in your settings.py under INSTALLED_APPS.如果是这样,首先要检查的是您的应用程序名称是否与 settings.py 中 INSTALLED_APPS 下指定的名称相匹配。

As pointed out in the comments, app names can be in the form [parent_app].[app_name].正如评论中指出的那样,应用名称可以采用 [parent_app].[app_name] 的形式。 In this case, migrate needs [app_name] only.在这种情况下,迁移只需要 [app_name]。

Your app must contain a models.py file (even emtpy).您的应用程序必须包含一个models.py文件(甚至是空文件)。

Source: https://groups.google.com/forum/#!msg/django-users/bsTZEmxgDJM/wH0p3xinBWIJ资料来源: https ://groups.google.com/forum/#!msg/django-users/bsTZEmxgDJM/wH0p3xinBWIJ

Just to mention another possible reason:再提一个可能的原因:

In my Django app i added the correct migrations and installed the app with pip and got the same error.在我的 Django 应用程序中,我添加了正确的迁移并使用 pip 安装了该应用程序,但出现了同样的错误。

What i was missing is a correct MANIFEST.in file Also the parameter include_package_data in setup() from the setup.py file was not set to True .我缺少的是正确的 MANIFEST.in 文件此外,setup.py 文件中 setup() 中的参数include_package_data未设置为True

I am trying to upgrade from Django 1.6.7 to Django 1.7.1, so I have been trying to migrate my app.我正在尝试从 Django 1.6.7 升级到 Django 1.7.1,所以我一直在尝试迁移我的应用程序。

I have followed the django docs here .在这里关注了django 文档

I deleted the south from my installed apps.我从我安装的应用程序中删除了南。

In the migration directory, I delete the numbered migration files and the .pyc files but I kept the directory & __ init__.py file.在迁移目录中,我删除了编号迁移文件和 .pyc 文件,但我保留了目录和 __ init__.py 文件。

I then run :然后我运行:

python manage.py makemigrations your_app_name

I receive the following confirmation message:我收到以下确认消息:

Migrations for 'your_app_name':
  0001_initial.py:
    - Create model UserProfile

Next I run:接下来我运行:

python manage.py migrate your_app_name

I received the following error:我收到以下错误:

CommandError: App 'your_app_name' does not have migrations (you cannot selectively sync unmigrated apps)

As per the docs, I also ran:根据文档,我还运行了:

python manage.py migrate --fake your_app_name

I received the same error message:我收到了同样的错误信息:

CommandError: App 'your_app_name' does not have migrations (you cannot selectively sync unmigrated apps)

Can anyone shed some light on why this will not work for me?谁能解释为什么这对我不起作用?

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

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