测试Django Rest框架的问题

发布于 2025-02-13 04:37:27 字数 597 浏览 0 评论 0原文

我正在尝试执行DJANGO REST框架文档中的测试。无论我要测试什么,它总是会出现相同的错误。

测试示例:

class TestRequestFactory(APITestCase):

    def test_request(self):
        factory = APIRequestFactory()
        request = factory.post('/list_user/', json.dumps({'title': 'new idea'}), content_type='application/json')

我指的是我在许多地方都看过的错误

 django.db.utils.ProgrammingError: relation "user" does not exist LINE
 1: ...ted_by", "user"."created_ts", "user"."is_active" FROM "user"

,而解决方案一直相同,do manage.py迁移 manage.manage.py迁移 -假机器人零,我可以做所有的事情,但最终给出了相同的错误

I'm trying to perform the tests that are within the Django Rest Framework documentation. And it always gives the same error, regardless of what I'm testing.

Test example:

class TestRequestFactory(APITestCase):

    def test_request(self):
        factory = APIRequestFactory()
        request = factory.post('/list_user/', json.dumps({'title': 'new idea'}), content_type='application/json')

The error I'm referring to is this

 django.db.utils.ProgrammingError: relation "user" does not exist LINE
 1: ...ted_by", "user"."created_ts", "user"."is_active" FROM "user"

I've looked in many places and the solution has always been the same, do manage.py migrate or manage.py migrate --fake bots zero, I can do everything, but in the end it gives the same error

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文