Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'Module' Object Has no Attribute 'models' error in django

Tags:

python

django

I'm working on a simple blog engine. Here is my initial code for the models:

from django.db import models
from django.contrib.auth.models import User

class Entry(models.Model):

    title = models.CharField(max_length=80)
    author = models.models.models.ForeignKey(User)
    pubdate = models.DateTimeField()
    text = models.TextField()
    tags = models.ManyToManyField(Tag)


class Tag(models.Model):
    name = models.CharField(max_length=25)

class Comment(models.Model):
    author = models.ForeignKey(User)
    pubdate = models.DateTimeField()
    text = models.TextField()

When I try to run python manage.py syncdb blog, I get the error

'Module' Object Has no Attribute 'models'

I'm using sqlite3. I haven't set up any views or tests yet. In settings.py, I have included the following apps:

'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'blogApp',
'south',

Any ideas what could be going wrong here?

like image 261
user1427661 Avatar asked Apr 16 '13 17:04

user1427661


1 Answers

you have

author = models.models.models.ForeignKey(User)

that should probably be

author = models.ForeignKey(User)

instead.

like image 193
ch3ka Avatar answered Oct 17 '22 12:10

ch3ka