Ugh. Sorry for the confusion. Here again are the pieces where I need suggestions. Please suggest actual code. I can't decipher things written in plain language on forums. Code is key for me.
path('post/<int:pk>/', views.PostDetailView.as_view(), name='post_detail'), path('post/*random/???*', views.RandomDetailView.as_view(), name='random_post'), * ### I don't know what to put here* Also my view: def random_post(request): post_ids = Post.objects.all().values_list('post_id', flat=True) * ### Is 'post_id' correct? That's my field name that is my primary key* random_obj = Post.objects.get(id=random.choice(post_ids)) *### What do I put here? id? pk? post_id?* context = {'random_obj':random_obj,} return render(request, 'blog/random_post.html', context) I have tried a bunch of different configurations for my urlpattern. I have tried different variable names in my view. I'm not sure that my data is actually being inserted into my view. I don't know what my urlpattern is supposed to be. I don't know which variables to use in my view, regarding the primary key. -- 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/d5ba26c4-dacc-4ad4-9050-55c1f44cdd8c%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.