Я пытаюсь получить информацию об аватаре пользователя в расширенной модели профиля. Я обычно вызываю информацию через get_profile (). Однако в этом случае вызов находится внутри цикла for в шаблоне, и я получаю ошибки, если один из пользователей совпадает.
Как мне избежать этой ошибки?
{% for fevent in fevents %}
<!-- EVENT ><! -->
<div class="event">
<div class="pic">
<a href="" class="notification" title="{{ fevent.getPublishedPredictionsCount }} Predictions">{{ fevent.getPublishedPredictionsCount }}</a>
<img src="{% thumbnail fevent.artwork.get_absolute_url 100x98 crop,upscale %}" alt="" width="100" height="98" />
<div class="overlay">
<a href=""></a>
</div>
</div>
<h1><a href="">{{ fevent.title|trunchar:30 }}</a></h1>
{% autoescape off %}
{{ fevent.getEventPredictionScore|makestars }}
{% endautoescape %}
<ul class="details">
<li class="cat">
Category: <a href="">{{ fevent.catagory }}</a>
</li>
<li class="location">
{{ fevent.location }}
</li>
<li class="date">
{{ fevent.date_and_time }}
</li>
<li class="time">
7:00pm - 8:00pm
</li>
</ul>
<!-- CLEAR ><! --><div class="clear"></div>
<div class="hype">
<div class="avatar">
<a href="" class="overlay" title="{{ fevent.owner.get_full_name }}"></a><img src="{% thumbnail fevent.owner.get_profile.avatar.get_absolute_url 120x120 crop,upscale %}" alt="" width="120" height="120" />
</div>
<p>{{ fevent.description|trunchar:200 }}… <a href="">Read More</a></p>
</div>
<!-- CLEAR ><! --><div class="clear"></div>
</div>
<!-- END OF EVENT ><! -->
{% endfor %}
Проблема здесь:
{% thumbnail fevent.owner.get_profile.avatar.get_absolute_url 120x120 crop,upscale %}
Возвращено сообщение об ошибке:
Caught MultipleObjectsReturned while rendering: get() returned more than one UserProfile -- it returned 2! Lookup parameters were {'user__id__exact': 4L}