问题描述
这是settings.py中我已安装的应用程序部分.
This is my installed apps section in settings.py.
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'homepage.apps.HomepageConfig',
.
.
.
]
我的应用程序名称为"homepage",我真的不记得为什么将其更改为"homepage.apps.HomepageConfig",但是不管它是什么,它都可以在我的机器上使用.
My app name is "homepage" and I really can't remember why I changed it to 'homepage.apps.HomepageConfig', but whatever it is, it worked on my machine.
现在,我将文件上传到服务器,安装了必需的应用程序,进行了迁移,但是我注意到django不会创建我的主页"应用程序表,也不会从我的应用程序中迁移任何内容.而且我的网站返回错误:表homepage_post不存在.
Now, i uploaded my files to server, installed required apps, did the migrations, but i noticed django does not create my "homepage" app table and does not migrate anything from my app. And my website returns the error: table homepage_post does not exist.
怎么了?
推荐答案
检查是否在 homepage
应用程序目录中您具有名为 __ init __.py
和 apps的文件.py
. apps.py
的内容应为:
Check if in homepage
app directory You have file named __init__.py
and apps.py
. The content of apps.py
should be:
from django.apps import AppConfig
class HomepageConfig(AppConfig):
name = 'homepage'
这篇关于Django installed_apps无法识别我的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!