djangoによるデータ移行時の異常

3941 ワード

コマンドpython manage.py mikegrationsを使用してデータ移行を行うと、次の異常が発生します.
RuntimeError: Model class apps.app_user.models.user_profile doesn't declare an explicit app_laation in INSTALLED_APPS.

対応するコード・セグメントは次のとおりです.
from django.shortcuts import render
from django.db.models import Q
from .models import user_profile
from django.contrib.auth.backend import ModelBackend


def main_site(request):
	return render(request,'main_site.html')
	
class custom_backend(ModelBackend):
	def authenticate(self,username=None,password=None,**kwargs):
		try:
			user = user_profile.object.get(Q(username=username)|Q(email=username))#     Q      
			if user.check_password(password):
				return user
		except Exception as e:
			return None

これは、3行目でpython 3では相対パスの参照がサポートされていないため、次のコードに変更します.絶対パスを使用すればいいです.
from ap_user.models import user_profile