我刚开始使用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)
答案 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)