내 쿼리 세트는 현재 내보기에 posts
입니다. 그러나 사용자가 new
url로 이동할 때 내 쿼리 세트를 Post.objects.all().filter(category=category).order_by('-date')
으로 변경하고 싶습니다.보기에서 변수 값을 변경하는 방법은 무엇입니까?
URL을
url(r'^$', boxes_view, name='home'),
url(r'^new/$', boxes_view, name='new'),
전망
def boxes_view(request):
...
posts = Post.objects.all().filter(category=category).annotate(score_diff=F('score__upvotes') - F('score__downvotes')).order_by('-score_diff')
템플릿
...
<button id="sort_new"><a href="{% url 'new' %}">New</a></button>
new
URL을 통해 갈 때 posts
의 값을 변경할 수 있습니다 : 여기 내 코드는?
이것은 의미가 없습니다. 두 개의 동일한 URL을 가질 수 없습니다. –
내 실수. – Zorgan