Okay so I have a homepage that displays images. This is accessed from my images tables. It contains a column of the owner, in the form of a user id. I also have a table of users, who've submitted those images. How do I make it so that when displaying images, it uses the ID to get the useame from the user table?
views.py:
def index(request):
context = {}
populateContext(request, context)
context.update(gallery=ImageDoc.objects.only('thumbfile').order_by('-id'))
retu render(request, 'register/index.html', context)
So in the index.html page, I can iterate through 'gallery' to show the images. Like so:
{% for image in gallery %}
<a href="/logo/{{ image.slug }}">
<img src="{{ MEDIA_URL }}{{ image.largethumbfile }}">
{{ image.title }} by {{ image.useame }} for {{ image.price }}
</a>
{% endfor %}
"image.useame" obviously doesn't work. I know I need to access the users table with this:
get_users = User.objects.get()
And reformat grabbing the images data to this:
get_images = ImageDoc.objects.get()
But I don't know the next step to ensure the data matches. Any ideas? Thank you!
