django user images

Xristos Xristoou saxri89 at
Tue Apr 11 10:36:28 EDT 2017


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 ?
class MyModel(models.Model):
    user = models.ForeignKey(User, unique=True)
    photo = models.ImageField(upload_to='images')

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 %}
          <td><a href="{{ photo.file.url }}">{{ }}</a></td>
      {% endfor %}

More information about the Python-list mailing list