There is the following structure - 2 applications: account and question . In the account application, a user is created and a photo is added. In the question application, the user can create questions.

File models.py account applications

class Profile(models.Model): user = models.OneToOneField(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) photo = ProcessedImageField(upload_to='users/', blank=True, processors=[ResizeToFill(300, 300)], format = 'JPEG', options={'quality': 100}) 

File question.py application question

 class Question(models.Model): title = models.CharField(max_length=250) author = models.ForeignKey(User, related_name='user_question', on_delete=models.CASCADE, default='') ... 

When adding a user question to the site, I need to display information about the question through the Question model. All information is displayed, but I do not know how to access the photo field. Help to deal with this task.

    1 answer 1

     <img src="{{ some_question.author.profle.photo.url }}"> 
    • Great, it works. Thank you - Simple User