DjangoRuntimeError: Model class doesn't declare an explicit app_label

运行环境
PyCharm 2017.1 
Django 1.1.11
python 2.7

使用相对路径引用Models模块
from .models import *
1
在同时存在多个apps的情况下,有机会报错

RuntimeError: Model class app_anme.models.Ad doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
1
解决办法
使用绝对路径引用

from app_name.models import *

猜你喜欢

转载自blog.csdn.net/myli_binbin/article/details/85273749