Answer the question
In order to leave comments, you need to log in
Django how to attach file submissions to a feedback form?
Guys tell me there is a form
How can I implement the ability to attach files (Images) in it
Answer the question
In order to leave comments, you need to log in
Hello:
1) You add an image storage field to the model, for example ImageField:
2) If the forms are automatically created from the model, then this field has already appeared, if you collect the forms with your hands, then you get something by type in the forms.py file:
class Profile_Form(forms.Form):
avatar = forms.ImageField(label='Загрузить Аватар', required=False)
myself = forms.CharField(....)
myoffer = forms.CharField(...)
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question