What you need is actually very simple. Create a 'random_post' URL, which points to a view doing the shuffle logic and returns a redirect to the proper page, say '/post/$id', then make that a valid URL and use a DetailView.
On January 7, 2018 4:32:11 PM GMT+03:00, Ronnie Raney <[email protected]> wrote: >If I understand you, you suggest using my existing DetailView url which >shows the detailed Post, but create a view which selects a random pk. > >I thought of this but I don’t know how to go about creeating a view >that selects a random pk, then applies to the existing urlpattern. > >My guess is to count() the Post objects, then randomly pick one of the >objects. Then somehow grab the primary key, post_id, and somehow insert >into a urlpattern. Also point to the correct template. Any help >appreciated! m712 -- https://nextchan.org -- https://gitgud.io/blazechan/blazechan I am awake between 3AM-8PM UTC, HMU if the site's broken -- 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/7F10E576-DF89-4403-B958-CCCC3B4D62B9%40getbackinthe.kitchen. For more options, visit https://groups.google.com/d/optout.

