在views中引用UserProfile报错RuntimeError: Model class apps.users.models.UserProfile doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

如图报错,在settings中,该加的也加了啊!

显然类似于网上最容易遇到的解决方案如下图,是没有任何意义的

只要在view中有

from .models import UserProfile,VerifyCode

一运行项目就会报错!怎么破?

其实很简单,只要在views中这样写就可以了。

from users.models import UserProfile,VerifyCode

再运行一下项目,是不是就不报错,可以正常使用啦?

猜你喜欢

转载自www.cnblogs.com/xuepangzi/p/9067547.html