'模块'对象在django中没有属性'模型'错误

时间:2022-01-26 08:40:15

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

当我尝试运行python manage.py syncdb博客时,我收到错误

'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:

我正在使用sqlite3。我还没有设置任何观点或测试。在settings.py中,我包含了以下应用:

'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 个解决方案

#1


7  

you have

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

that should probably be

应该是这样的

author = models.ForeignKey(User)

instead.

#1


7  

you have

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

that should probably be

应该是这样的

author = models.ForeignKey(User)

instead.