“没有这样的表”如何解决Django管理问题?

2024-06-17 13:41:19 发布

您现在位置:Python中文网/ 问答频道 /正文

我能够按照William S.Vincent的书“Django for初学者”中关于创建和激活数据库模型的说明进行操作。我能够到达第一张图片,但在那之后,“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)

1. I am able to follow the instructions to this point given in the book "Django for Beginners" by William S. Vincent but when I am trying to save the content getting the following error

2. this is the error browser page


1条回答
网友
1楼 · 发布于 2024-06-17 13:41:19

当您错过makemigrations或migrate时会发生此错误,因此该表在数据库中不可用

因此,请运行以下命令:

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

如果上述操作不起作用,请删除数据库并重试这些操作

相关问题 更多 >