django user images
Xristos Xristoou
saxri89 at gmail.com
Tue Apr 11 10:36:28 EDT 2017
hello
if i want to create a query in django with to take all images and preview that list in html like easy work.
but if want in html page preview only the personal images where login user what changes i need in my code ?
model.py
class MyModel(models.Model):
user = models.ForeignKey(User, unique=True)
photo = models.ImageField(upload_to='images')
views.py
class BasicUploadView(request):
photos_list = Photo.objects.all()
return render(request, 'photos/basic_upload/index.html', {'photos': photos_list})
html page :
{% for photo in photos %}
<tr>
<td><a href="{{ photo.file.url }}">{{ photo.file.name }}</a></td>
</tr>
{% endfor %}
More information about the Python-list
mailing list