5

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?

1
  • Have you named your project or any other files django? You could have a name collision for the module name on the PYTHONPATH. Also, is the error on the first or second import? Commented Apr 16, 2013 at 17:36

1 Answer 1

8

you have

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

that should probably be

author = models.ForeignKey(User)

instead.

Sign up to request clarification or add additional context in comments.

2 Comments

Good catch, I didn't even notice that... of course a stack trace would have made it somewhat more obvious...
django swallows the stacktrace by default

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.