如何使用 "no such table" 解决 Django 管理问题?

How to resolve Django Administration Problem with "no such table"?

我能够按照 William S. Vincent 的“Django for Beginners”一书中关于创建和激活数据库模型的说明进行操作。我能够到达第一张图片,但在那之后 'get' 和 'post' 请求可能无法正常工作。 添加我的 models.py 代码:

    from django.db import models

class Post(models.Model):
    text = models.TextField()

以下内容来自 admin.py 文件:

from django.contrib import admin

from .models import Post
admin.site.register(Post)

当您错过 makemigrations 或迁移时会发生此错误,因此 table 在数据库本身中不可用。

因此 运行 以下命令:

  1. python manage.py makemigrations
  2. python manage.py 迁移

如果上述方法无效,请删除数据库并再次尝试。