I'm building a personal photography site using Django. I'm working on the models.py. My app is called "photoViewer", the site is called "photoSite". However, when I run makemigrations, I'm getting:
NameError: name 'ImageField' is not defined
I have 3 images stored in "photoSite\photoViewer\static\photoViewer\images"
locally, that I'd like to display on my completed site.
Models.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
settings.py:
...
MEDIA_ROOT = os.path.join(os.path.dirname(__file__), '..', 'static').replace('\\','/')
STATIC_URL = '/static/'
...