Hi,
I have a log table with a foreign key to the user table, and a userprofile table with a one to one field to the user table:
class Log(models.Model):
user = models.ForeignKey(User)
...
class UserProfile(models.Model):
user = models.OneToOneField(User)
picture = models.ImageField(upload_to='profile_images', blank=True)
...
In my ListView I want to get the user profile for each log. I know I can use select_related to get the related users of the log as follows:
queryset = Log.objects.select_related('user').order_by('created')
... but how do I get the related profiles and pass these on to the template, so I can for example display the picture for each log?
Thanks