i am making simple model in videorequest app
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)
what's wrong in my code
cmd showing me while i am trying to run python manage.py runserver query
Unhandled exception in thread started by .wrapper at 0x0446E7C8>
Traceback (most recent call last):
File "C:\Users\HP\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "C:\Users\HP\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\commands\runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "C:\Users\HP\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\utils\autoreload.py", line 248, in raise_last_exception
raise _exception[1]
File "C:\Users\HP\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management__init__.py", line 337, in execute
autoreload.check_errors(django.setup)()
File "C:\Users\HP\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "C:\Users\HP\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\HP\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\apps\registry.py", line 112, in populate
app_config.import_models()
File "C:\Users\HP\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\apps\config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File "C:\Users\HP\AppData\Local\Programs\Python\Python37-32\lib\importlib__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1006, in _gcd_import
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in _load_unlocked
File "", line 728, in exec_module
File "", line 219, in _call_with_frames_removed
File "F:\python_project\05project\mywebsite\videorequest\models.py", line 4, in
class Video(models.model):
AttributeError: module 'django.db.models' has no attribute 'model'
Best Answer
in line 4 in class Video(models.model): AttributeError: module 'django.db.models' has no attribute 'model'
I think you have typo mistake. models do not have model instead it have Model. convert
Convert
to