进行迁移命令

时间:2020-06-26 11:22:35

标签: python django web

我刚开始使用python学习django。当我尝试运行命令"python manage.py make migrations"时,我看到了error "module 'django.db.models' has no attribute 'models'"。 我该如何解决?(我留下了代码,错误记下了。)

from django.db import models

class Article(models.Model):
author = models.ForeignKey("auth.User",on_delete = models.CASCADE)
title = models.CharField(max_length=50)
content = models.TextField()
created_date = models.DateTimeField(auto_now_add = True)

Error

1 个答案:

答案 0 :(得分:1)

语法错误

models.models.CharField(max_length=50)

您两次调用模型。

尝试一下

from django.db import models

class Article(models.Model):
author = models.ForeignKey("auth.User",on_delete = models.CASCADE)
title = models.CharField(max_length=50)
content = models.TextField()
created_date = models.DateTimeField(auto_now_add = True)
相关问题