Наши пользователи загружают фотографии с помощью form.py ProfileForm, который в настоящее время позволяет только администратору загружать фотографии на сайт. Мы добавили enctype = "multipart / form-data" в наш html, который отображает форму, но он по-прежнему не позволяет пользователю загружать свои фотографии.
class ProfileForm (forms.ModelForm):
class Meta:
model = Profile
fields = ('nickname', 'gender', 'age', 'height', 'location', 'job_title', 'education', 'hometown', 'drinker', 'smoker', 'photo_one', 'photo_two', 'photo_three', 'prompt_one', 'prompt_two', 'prompt_three', 'age_preference_max', 'age_preference_min', 'gender_preference')
{% extends 'base.html'%}
{% block content%}
<form method="POST" enctype="multipart/form-data">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Save</button>
</form>
{% endblock%}
photo_one = models.ImageField (upload_to = 'photos', blank = True)
photo_two= models.ImageField (upload_to = 'photos', blank = True)
photo_three = models.ImageField (upload_to = 'photos', blank = True)