Skip to content

Commit

Permalink
Ошибка, связанная с ошибкой с неизвестным полем в сортировке
Browse files Browse the repository at this point in the history
  • Loading branch information
nyafka committed Mar 15, 2016
1 parent a75e9e6 commit 40efe3a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lbforum/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from django.shortcuts import render, get_object_or_404
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User
from django.core.exceptions import FieldError
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ugettext
from django.core.urlresolvers import reverse
Expand Down Expand Up @@ -42,8 +43,14 @@ def forum(request, forum_slug, topic_type='', topic_type2='',
#topic_type = _("Distillate District")
if topic_type2:
topics = topics.filter(topic_type__slug=topic_type2)

order_by = request.GET.get('order_by', '-last_reply_on')
topics = topics.order_by('-sticky', order_by).select_related()

try:
topics = topics.order_by('-sticky', order_by).select_related()
except FieldError:
topics = topics.order_by('-sticky', '-last_reply_on').select_related()

form = ForumForm(request.GET)
ext_ctx = {'form': form, 'forum': forum, 'topics': topics,
'topic_type': topic_type, 'topic_type2': topic_type2}
Expand Down

0 comments on commit 40efe3a

Please sign in to comment.