ImageField不是定义的

2024-09-27 07:24:37 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在用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}$

Tags: py模型self名称heretitle网站models

热门问题