On Mon, Jan 8, 2018 at 1:37 PM, Ronnie Raney <theroni...@gmail.com> wrote:

> 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.
>

OK, first, calm down, seems that your feelings aren't letting you think and
you are "running in circles". Code is a language, just as English, you can
understand both, you just need to read it slowly and calmed.


>
>     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*
>

No id and point it to the FBV:

>     path('post/*random/*', views.random_post, 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? YES That's my field name that is my primary
> key*
>         random_obj = Post.objects.get(post_id=random.choice(list(post_ids)
> ))
> *### What do I put here? id? pk? post_id? -> You may have to convert the
> queryset to a list / evaluate but I'm not sure, you'll have to ty it*
>         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.
>

Calm down, yes you do, just re-read the thread slowly and you'll find the
answers :)


> --
> 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
> <https://groups.google.com/d/msgid/django-users/d5ba26c4-dacc-4ad4-9050-55c1f44cdd8c%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CA%2BFDnhJULft7MhQUXEF2sitqSZxKSn5ixbtt6HznXdwUX%2BpV0w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to