Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 我该如何处理这个问题;Django-数据库错误:没有这样的表;错误?_Python_Django - Fatal编程技术网

Python 我该如何处理这个问题;Django-数据库错误:没有这样的表;错误?

Python 我该如何处理这个问题;Django-数据库错误:没有这样的表;错误?,python,django,Python,Django,我是django的新手,我一直在解决模型的问题。以下是我的用户应用程序的模型文件: from django.db import models from django.contrib.auth.models import User from django.core.validators import MinValueValidator, MaxValueValidator from django.urls import reverse from PIL import Image class

我是django的新手,我一直在解决模型的问题。以下是我的用户应用程序的模型文件:

from django.db import models
from django.contrib.auth.models import User
from django.core.validators import MinValueValidator, MaxValueValidator
from django.urls import reverse
from PIL import Image




class Schedule(models.Model):
    title = models.CharField(max_length=150)
    context = models.TextField()


class Input(models.Model):
    DAYS_OF_FITNESS = [
       ('month', '30'),
       ('month_2', '60'),
       ('month_3', '90'),
   ]
    weight = models.PositiveIntegerField(validators=[MinValueValidator(40)])
    age = models.PositiveIntegerField(validators=[MinValueValidator(12)])
    days = models.CharField(
    max_length=20, choices=DAYS_OF_FITNESS, default='30')
    athlete = models.OneToOneField(User, primary_key=True, on_delete=models.CASCADE)
    schedule = models.ForeignKey(Schedule, on_delete=models.CASCADE)
我正在尝试使用OneToOneField将每个用户与其输入链接起来,并将Schedule作为外键链接到输入模型

但当我尝试迁移模型时,会出现以下错误:

return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: no such table: users_input

我检查了这两个模型是否都在django设置中,并移植了它们。顺便说一句,我使用信号自动保存输入(如果有帮助,请注意)

这是因为数据库中不存在该表。要创建表,必须执行以下操作。在终端中执行以下命令

python manage.py makemigrations


python manage.py migrate

您是否迁移了数据库更改我迁移了每个更改当我运行python manage.py makemigrations时,没有检测到任何更改,但当我运行python manage.py migrate时,我没有得到这样的表:users\u input error