Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在自定义路径中创建迁移django模型?_Python_Django - Fatal编程技术网

Python 如何在自定义路径中创建迁移django模型?

Python 如何在自定义路径中创建迁移django模型?,python,django,Python,Django,我想用python(django)+javascript创建一个练习web游戏 我的项目名称是路西法 路径是 ├── Makefile ├── README.md ├── lucifer │   ├── db.sqlite3 │   ├── game │   │   ├── __init__.py │   │   ├── character │   │   │ ├── __init__.py │   │   │ └── models │   │   │ ├── __init_

我想用python(django)+javascript创建一个练习web游戏

我的项目名称是路西法

路径是

├── Makefile
├── README.md
├── lucifer
│   ├── db.sqlite3
│   ├── game
│   │   ├── __init__.py
│   │   ├── character
│   │   │   ├── __init__.py
│   │   │   └── models
│   │   │       ├── __init__.py
│   │   │       └── character.py
│   │   └── skill
│   │       ├── __init__.py
│   │       └── models
│   │           ├── __init__.py
│   │           └── skill.py
│   ├── lucifer
│   │   ├── __init__.py
│   │   ├── settings
│   │   ├── templates
│   │   ├── urls.py
│   │   ├── views
│   │   └── wsgi.py
│   ├── manage.py
│   ├── posts
│   │   ├── __init__.py
│   │   ├── forms.py
│   │   ├── models
│   │   ├── templates
│   │   └── views
│   └── users
│       ├── __init__.py
│       ├── admin
│       ├── models
│       ├── templates
│       └── views
该应用程序包括帖子、用户和游戏

游戏应用程序中有游戏模型

已安装的应用程序

INSTALLED_APPS = [
    # ... #

    'rest_framework',
    'django_summernote',

    'lucifer',
    'users',
    'posts',

    'game',
]
当I
manage.py makemigrations用户发布游戏时

角色、技能模型不会迁移

如何使迁移成为我的游戏模型

多谢各位

game/\uuuu init\uuuuu.py

from .character import models
from .skills import models
# none
from models.character import Character
# none
from models.skill import Skill
game/character/\uuuuu init\uuuuuuu.py

from .character import models
from .skills import models
# none
from models.character import Character
# none
from models.skill import Skill
游戏/角色/模型/\uuuuu init\uuuuuu.py

from .character import models
from .skills import models
# none
from models.character import Character
# none
from models.skill import Skill
游戏/技能/\uuuuuuuuuuuuuuuu.py

from .character import models
from .skills import models
# none
from models.character import Character
# none
from models.skill import Skill
游戏/技能/模型/\uuuuuuuuuuuuuuuuu.py

from .character import models
from .skills import models
# none
from models.character import Character
# none
from models.skill import Skill

对于角色和技能,您有不同的文件夹结构,您是否进行了任何更改以接受此结构

如果您不需要,可以将您的角色和技能模型放入models.py并删除其模型目录:

│   ├── game
│   ├── __init__.py
│   └── character
│   │   ├── __init__.py
│   │   └── models.py
│   └── skill
│       ├── __init__.py
│       └── models.py
│   ...
编辑:

在任何情况下,要调用的应用程序的名称都是角色和技能,而不是游戏应用程序

python manage.py makemigrations character
您可以看到受迁移影响的应用程序

python manage.py migrate --list

在init中导入所有模型。py@SHIVAMJINDAL谢谢你的建议,但是不起作用。你能把所有的信息都显示出来吗。py@SHIVAMJINDAL我添加init.py谢谢@SHIVAMJINDAL Umm我使用Appconfig解决了我的问题,但是,非常感谢您的建议。尝试查看您的应用程序:manage.py migrate--list(您的应用程序应该是角色和技能,而不是游戏)