using django.VERSION (2, 1, 5, 'final', 0) with

python 3.7.2 on ubuntu 16.04

Given the URL pattern below:

path('<int:pk>', ArticleDetailView.as_view(), name='article_detail'),

And the view as below:

class ArticleDetailView(DetailView):
    model = Article
    template_name = 'article_detail.html'
    login_url = 'login'

I can access the variable pk from a template as

article.pk

But I don't know how to access the pk variable from the view itself.

Adding the get_queryset method to the view doesn't work

example

def get_queryset(self):
        print(self.kwargs["pk"])

results in

'NoneType' object has no attribute 'filter' Trying def get_object(self): queryset = self.filter_queryset(self.get_queryset()) obj = queryset.get(pk=self.kwargs['pk']) return obj results in 'ArticleDetailView' object has no attribute 'filter_queryset' Please advise - pretty basic for django, new to me :) thanks

--
Tim
tj49.com

--
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e712d934-332a-aaa9-54cd-19aeaf8552a4%40akwebsoft.com.

Reply via email to