1. ditto
  2. foodcapsule

Commits

ditto  committed d66046c

* 테스트 통과하게 수정
* 최근 위치 중복 제거

  • Participants
  • Parent commits 4451e00
  • Branches default

Comments (0)

Files changed (2)

File foodcapsule/post/models.py

View file
     post = models.ForeignKey(Post)
 
 def get_recent_locations(user):
-    qs = Post.objects.filter(user=user).exclude(location='').order_by('-id')
-    return qs.values_list('location', flat=True)
+    from django.db import connection
+    cursor = connection.cursor()
+    cursor.execute("""
+        SELECT DISTINCT location
+        FROM post_post
+        WHERE location != '' AND user_id=%s
+        ORDER BY id DESC
+    """, [user.id])
+    return [row for (row,) in cursor]

File foodcapsule/templates/user.html

View file
 {% endif %}
 
 <div id="profile-header">
-{% if owner != user %}
+{% if user.is_authenticated and owner != user %}
     <p class="friend-status">{% add_friend_link owner %}</p>
 {% endif %}