This is my model
class MenuOptions(models.Model):
name = models.CharField(max_length=500, null=False)
description = models.CharField(max_length=500, null=True)
image_url = models.CharField(max_length=1000, null=True)
This is my form
class MenuOptionsForm(forms.ModelForm):
class Meta:
model = MenuOptions
fields = ['name', 'description']
And this is my view
if request.method == 'POST':
form = MenuOptionsForm(request.POST)
if form.is_valid():
form.save()
return redirect('menu-options')
else:
form = MenuOptionsForm()
I want to have the custom image field using Django form so that I can use that in the template to upload the image on S3/Google storage. I know how to upload the image on the bucket, and after uploading the image to the storage I want to save only the image_url to the DB, not the image. So it can not be an image_filed in the Django model it has to be a string.