Show all images per Profile

13 views
Skip to first unread message

Sebastian Jung

unread,
Aug 11, 2019, 4:22:11 PM8/11/19
to Django users
Hello,

i have a extend User Model like this:

class Profile(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
telefon = encrypt(models.CharField(max_length=70,default="",null=True))



and a class with documents incl. fotos:

class Document(models.Model):
profile_link = models.ForeignKey(Profile, blank=True,null=True, on_delete=models.SET_NULL,related_name="document_profile_link")

Now in html template i want that all fotos per profile is show:

{% for Profile in Profiles %}
{% for Document in Documents %}
{% if '.png' in document.file or '.jpg' in document.file %}
<td> <img src="{{document.file}}" alt="" height="42" > </td>
{% else %}
<td>No Image</td>
{% endif %}
{% endfor %}


{% endfor %}

Where can i link for Documents loop to Profile?

Regards


Reply all
Reply to author
Forward
0 new messages