4

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'

8
  • 3
    That is not your code. Your code has models.model, not models.Model. Commented Feb 26, 2019 at 16:41
  • from where you are actually getting this error. Can you please add your error-traceback Commented Feb 26, 2019 at 16:45
  • when i try to run python manage.py runserver command @shakil Commented Feb 26, 2019 at 17:00
  • @DanielRoseman no my code have models.Model only Commented Feb 26, 2019 at 17:01
  • It is just fine when i ran. Which django version your are using?. Please add your error. Commented Feb 26, 2019 at 17:02

1 Answer 1

10

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

Video(models.model)

to

Video(models.Model)
Sign up to request clarification or add additional context in comments.

2 Comments

which django version you are using ?
Maybe you should point out that the problem is due to the Django version

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.