from django.conf.urls import url
#从绝对路径导包会报错
# from meiduo.apps.users import views
from . import views
urlpatterns=[
# url(r'^$ ',views)
url(r'^usernames/(?P<username>\w{5,20})/count/$', views.UsernameCountView.as_view()),
url(r'^mobiles/(?P<mobile>1[3-9]\d{9})/count/$', views.MobileCountView.as_view()),
url(r'^users/$', views.UserView.as_view()),
]
from meiduo.apps.users import views这种导包方式就会报错,查了一下多说 INSTALLED_APPS的问题,但是实际好像也没啥关系,跟老师代码对比一下,发现换成相对路径就好了,原因未知…
错误信息如下:
RuntimeError: Model class meiduo.apps.users.models.User doesn’t declare an explicit app_label and isn’t in an application in INSTALLED_APPS.
项目目录结构