Django多重复制

时间:2017-02-28 05:50:40

标签: django django-notification

我使用的是django通知,但是当未读通知增加时,加载时间和重复次数也会增加。如何优化此代码?

            {% for notification in request.user.notifications.unread %}
            <li><div class="media">
                    <div class="media-left">
                      <div class="media-object">
                        <img data-src="holder.js/50x50?bg=cccccc" class="img-circle" alt="50x50" style="width: 50px; height: 50px;" 
                        src="{{ BASE_DIR}}/media/profile_pictures/{{notification|getNotifUser}}/profile.jpg" data-holder-rendered="true">
                      </div>
                    </div>
                    <div class="media-body">
                      <strong class="notification-title">
                        <a id="{{ notification.target_object_id }}" class="{{ notification.pk }}">
                          {{ notification.actor_object_id|get_username}}&nbsp;{{notification.verb}} - request {{notification.target_object_id}}</a></strong>
                      <div class="notification-meta">
                        <small class="timestamp">{{ notification.timesince | getLocalTimeDifference}} əvvəl</small>
                      </div>
                    </div>
            </div> </li>
            {% endfor %} 

0 个答案:

没有答案