I have a template where the user can input data about himself, and upload his photo. Photo uploading will be done using ajax, with a separate upload button inside the form. My question is how do I upload the photo (when the user clicks on the upload button) and then save the user info when the user clicks on the submit button.
The model looks like this:
class User(models.Model):
name = models.CharField(max_length=50)
# some other fields
image = models.ImageField(upload_to="assets/images")
Thanks!
You could return the id of the User instance you used to save the picture as part of your js callback/success function, use it to populate a hidden field, and then call that user instance and save the rest of the info when the user submits the form.
The bigger question is, especially given that the user is going to submit the form anyway, why do you want to save just the image first?