Thanks - for clarification. Yes! good advice on remaining calm. Apologies if I seemed intense.
If I use this urlpattern, it takes me to the correct template. *path('post/random/', views.random_post, name='random_post'),* But there is no data. I really wanted to include the pk in the URL, to see which one it was picking at random. But it appears the data is not being queried correctly, or it's not being sent over as part of the view. Revised view: *def random_post(request):* * post_ids = Post.objects.all().values_list('post_id', flat=True)* * random_obj = Post.objects.get(post_id=random.choice(list(post_ids))) I am still unsure if this is the correct variable. * * context = {'random_obj':random_obj,}* * return render(request, 'blog/random_post.html', context)* Also, the here are my imports. Maybe there's something missing: *from django.shortcuts import render, redirect* *from .forms import ContactForm* *from django.http import HttpResponse, HttpResponseRedirect* *from django.shortcuts import render, redirect* *from django.core.mail import send_mail, BadHeaderError* *from django.http import HttpResponse, HttpResponseRedirect* *from django.utils import timezone* *from .models import Book, Writer, Translator, Post* *import random* -- 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/7f118b95-c122-4fc3-bfee-f1d008919b5d%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.