Answer the question
In order to leave comments, you need to log in
How to save a user's photo and change it?
For some reason I can't figure out how to save user files/photos to a folder and change them.
You can give an example of an ImageField to anyone who is not difficult - models.py, views.py, html on DJANGO.
Answer the question
In order to leave comments, you need to log in
models.py
photo= models.ImageField(verbose_name='Фотография',
upload_to='photos/%Y/%m/%d',
blank=True)
<div class="user_img">
<img src="{% if user.photo %}{{ user.photo.url }}{% else %}{% static 'sysadmins/img/avatar.jpg' %}{% endif %}" alt="">
</div>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question