Here, i am using three image fields in PostAd form. Images are not saved to the media folder. Can anyone help me please.
class classifieds(models.Model):
title = models.CharField(max_length=60)
description = models.CharField(max_length=600)
price = models.IntegerField()
image = models.ImageField(upload_to='photo/', null=True, blank=True)
image2 = models.ImageField(upload_to='photo/', null=True, blank=True)
image3 = models.ImageField(upload_to='photo/', null=True, blank=True)
added_date = models.DateTimeField(editable=False)
modified_date = models.DateTimeField()
In settings.py:
MEDIA_ROOT = os.path.join(BASE_DIR,'media')
MEDIA_URL = '/media/'
In urls.py(project urls):
urlpatterns += static(settings.MEDIA_URL,
document_root=settings.MEDIA_ROOT)
In views.py:
snippet of views.py
if request.method == 'POST':
title = request.POST['title']
description = request.POST['description']
price = request.POST['price']
image = request.POST['image']
image1 = request.POST['image1']
image2 = request.POST['image2']
I am getting this error
Thanks in advance