I have this code to submit the form:
form = form_class(request.POST, request.FILES, instance=object)
if form.is_valid():
form.save()
image_path = models.ImageField(upload_to='books/')
Currently books/book1/jpg
gets inserted into that field.
But I want that the image should be renamed to modelName_pk
.jpg and that value gets saved in image_path
How can I achieve that?