changeset 680:91de9b15b410

For Django 1.5.2: select_related's depth argument is deprecated.
author Brian Neal <bgneal@gmail.com>
date Thu, 15 Aug 2013 20:35:02 -0500
parents 89b240fe9297
children 53a56d19568c
files forums/management/commands/topic_export.py forums/views/main.py
diffstat 2 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/forums/management/commands/topic_export.py	Thu Aug 15 20:14:33 2013 -0500
+++ b/forums/management/commands/topic_export.py	Thu Aug 15 20:35:02 2013 -0500
@@ -48,7 +48,7 @@
         except Topic.DoesNotExist:
             raise CommandError('topic ID does not exist')
 
-        posts = topic.posts.select_related(depth=1)
+        posts = topic.posts.select_related('user')
 
         try:
             content = render_to_string(template_name, {'topic': topic, 'posts':
--- a/forums/views/main.py	Thu Aug 15 20:14:33 2013 -0500
+++ b/forums/views/main.py	Thu Aug 15 20:35:02 2013 -0500
@@ -1,5 +1,6 @@
 """
 Views for the forums application.
+
 """
 import collections
 import datetime
@@ -169,7 +170,7 @@
     topic.view_count = F('view_count') + 1
     topic.save(force_update=True)
 
-    posts = topic.posts.select_related(depth=1)
+    posts = topic.posts.select_related('user')
 
     paginator = create_post_paginator(posts)
     page_num = get_page_num(request)
@@ -260,7 +261,7 @@
     topic_url = reverse('forums-topic_index', kwargs={'id': id})
 
     if request.user.is_authenticated():
-        topic = get_object_or_404(Topic.objects.select_related(depth=1), pk=id)
+        topic = get_object_or_404(Topic.objects.select_related('forum', 'user'), pk=id)
         try:
             tlv = TopicLastVisit.objects.get(user=request.user, topic=topic)
         except TopicLastVisit.DoesNotExist:
@@ -290,7 +291,7 @@
     This view shows the latest (last) post in a given topic.
 
     """
-    topic = get_object_or_404(Topic.objects.select_related(depth=1), pk=id)
+    topic = get_object_or_404(Topic.objects.select_related('forum', 'user'), pk=id)
 
     if topic.last_post:
         return _goto_post(topic.last_post)