AttributeError:模块“django.db.models”没有属性“model”

viv*_*odi 4 django django-models

我正在 videorequest 应用程序中制作简单的模型

from django.db import models

from django.utils import timezone

# Create your models here.

class video(models.Model):
    videotitle = models.CharField(max_length=40)
    videodesc = models.TextField()
    dateadded = models.DateTimeField(default=timezone.now)

    def __str__(self):
        return 'Name: {},Id: {}'.format(self.videotitle,self.id)
Run Code Online (Sandbox Code Playgroud)

当我尝试运行 python manage.py runserver 查询时,我的代码 cmd 显示出了什么问题

由 .wrapper 在 0x0446E7C8> 处启动的线程中出现未处理的异常回溯(最近一次调用最后一次):文件“C:\Users\HP\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\utils\ autoreload.py”,第 225 行,包装器 fn(*args, **kwargs) 文件“C:\Users\HP\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\ management\commands\runserver.py”,第 109 行,inner_run autoreload.raise_last_exception() 文件“C:\Users\HP\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\utils\ autoreload.py”,第 248 行,在 raise_last_exception raise _exception[1] 文件“C:\Users\HP\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management__init__.py” ,第337行,在执行autoreload.check_errors(django.setup)()文件“C:\Users\HP\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\utils\autoreload.py ”,第 225 行,包装器 fn(*args, **kwargs) 文件“C:\Users\HP\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django__init__.py”,第 24 行,在安装 apps.populate(settings.INSTALLED_APPS) 文件“C:\Users\HP\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\apps\registry.py”中,第 112 行,在填充 app_config.import_models() 文件“C:\Users\HP\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\apps\config.py”,第 198 行,在 import_models self 中。 models_module = import_module(models_module_name) 文件“C:\Users\HP\AppData\Local\Programs\Python\Python37-32\lib\importlib__init__.py”,第 127 行,在 import_module 中 return _bootstrap._gcd_import(name[level:],文件“”,第 1006 行,在 _gcd_import 文件“”,第 983 行,在 _find_and_load 文件“”,第 967 行,在 _find_and_load_unlocked 文件“”,第 677 行,在 _load_unlocked 文件“”,第 728 行,在 exec_module 文件中“”,第 219 行,在 _call_with_frames_removed 文件“F:\python_project\05project\mywebsite\videorequest\models.py”,第 4 行,在类 Video(models.model) 中: AttributeError: 模块 'django.db.models' 没有属性“型号”

bka*_*wan 8

在类 Video(models.model) 的第 4 行中: AttributeError: 模块 'django.db.models' 没有属性 'model'

我认为你有拼写错误。模型没有模型,而是有模型。转变

转变

Video(models.model)
Run Code Online (Sandbox Code Playgroud)

Video(models.Model)
Run Code Online (Sandbox Code Playgroud)