I've been looking for a solution for a while. I saw this solution to show the image instead of just the link to the image: Display image from ImageField by means of form
But now I need to add a button so they can upload a new picture.
Any solution to this? Thanks in advance!
THE CODE I HAVE ON FORMS.PY:
class ProfileUpdateForm(forms.ModelForm):
class Meta:
model = Profile
fields = ['profilePicture', 'coverPicture', 'description', 'job','organizationName','birthday', 'phone','country','city','church','education','website','blog','vlog', 'newsletter', 'mailNotification']
labels = {
'profilePicture':'<strong>Profile Picture</strong>',
'coverPicture':'<strong>Cover Picture</strong>',
'description':'<strong>Describe yourself</strong>',
'job':'<strong>Whats your job title/position?</strong>',
'organizationName':'<strong>Name of the organization you belong</strong>',
'birthday':'<strong>Birthday</strong> (YYYY-MM-DD)',
'phone':'<strong>Phone Number</strong>',
'country':'<strong>Country</strong>',
'city':'<strong>City</strong>',
'church':'<strong>Name of the local church you attend</strong>',
'education':'<strong>Tell us about your education</strong>',
'website':'<strong>Website</strong>',
'blog':'<strong>Blog</strong>',
'vlog':'<strong>Vlog</strong>',
'newsletter':'<strong>Suscribe to the Artventist newsletter</strong> (We hardly send one)',
'mailNotification':'<strong>Would you like to recive email notifications regarding activity related to your account?</strong>'
}
mailNotification = forms.ChoiceField(widget=forms.RadioSelect, label='<strong>Would you like to recive email notifications regarding activity related to your account?</strong>', choices=[(1, 'Instant'), (2, 'Daily'), (3, 'Weekly'),(0, 'No')])
profilePicture = ImageField(widget=PictureWidget, label='<strong>Profile Picture</strong>')
At the end I solved this displaying the form field by field in the HTML and just calling the image by <img src="url_to_picture">