我正在用Django建立一个个人摄影网站。我正在研究模型.py. 我的应用程序名为“photoViewer”,网站名为“photoSite”。但是,当我运行makemigrations时,我得到:
NameError: name 'ImageField' is not defined
我有3张图片存储在"photoSite\photoViewer\static\photoViewer\images"
本地,我想显示在我完成的网站上。在
在模型.py公司名称:
from django.db import models
# Create your models here.
class Photo (models.Model):
photo_title = models.CharField(max_length=200)
photo_img = ImageField(upload_to = "images/") #Error here
def __str__(self): # __unicode__ on Python 2
return self.photo_title
class Album (models.Model):
photos= models.ManyToManyField(Photo)
album_title = models.CharField(max_length=200)
def __str__(self): # __unicode__ on Python 2
return self.album_title
在设置.py公司名称:
^{pr2}$
看起来你有语法问题。。。在
应该是。。。在
^{pr2}$相关问题 更多 >
编程相关推荐