Please give me code. Sorry, I can't decipher plain language in forums very 
well, when talking about code.

My urlpattern:   

 path('post/<int:pk>/', views.PostDetailView.as_view(), name='post_detail'),
 path('post/*random*/*???*', views.random_post, name='random_post'),  *### 
What do I put here?*

My view:

def random_post(request):
        post_ids = Post.objects.all().values_list('*post_id*', flat=True) * 
 ### Is this correct? My field name is post_id - the primary key.*
        random_obj = Post.objects.get(*pk*=random.choice(post_ids))   *### 
What do I put here? pk, id, post_id?*
        context = {'random_obj':random_obj,}
        return render(request, 'blog/random_post.html', context)

>
>

-- 
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/764fe76e-9d02-4c08-a4ae-f31346802a81%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to