鍍金池/ 問(wèn)答/Python  數(shù)據(jù)庫(kù)/ django relation "accounts_user&quot

django relation "accounts_user" does not exist

我的django項(xiàng)目

Subject
    accounts
    courses
        views.py
        tests
            test_models.py
    subject
    

test_models.py:

from django.core.urlresolvers import reverse

from django.test import TestCase

from .models import MultiSubject
from accounts.models import User

class DjanoRestFrameworkTests(TestCase):

    def setUp(self):
        part=Part.objects.get(pk=2)
        MultiSubject.get_or_create(part=part, number=1, title='多選題', description='多選題:水可以用來(lái)干什么?')

    def test_MultiSubject(self):
        title = MultiSubject.get(title='多選題')
        description = MultiSubject.get(description='多選題:水可以用來(lái)干什么?')
        self.assertEqual(
            title.get_title, "多選題 題目是: 多選題:誰(shuí)可以用來(lái)干什么?"
        )

運(yùn)行python manage.py test報(bào)錯(cuò)
django.db.utils.ProgrammingError: relation "accounts_user" does not exist

clipboard.png
但是數(shù)據(jù)庫(kù)中
這個(gè)表是存在的

clipboard.png

python manage.py makemigrations和python manage.py miagrate都可以正常執(zhí)行
請(qǐng)問(wèn)是什么原因

回答
編輯回答
未命名

from accounts.models import User

accounts.models里有定義User模型么?

2018年3月16日 16:36