Here's a view that works, in case someone in the future wants cares about
this
def random_post(request):
post_count = Post.objects.all().count()
random_val = random.randint(0, post_count-1)
post_id = Post.objects.values_list('post_id',
flat=True)[random_val]
return redirect('post_detail', pk=post_id)
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/41d8a830-c76c-42f8-b475-929603fe052d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.