I need to display a detail page for a video with some other data.
For that I use DetailView
that I have overridden to add some variables to the context.
Here are the code parts:
#urlconf
#...
(r'viewtube/(?P<pk>\d+)$', VideoFileDetailView.as_view()),
#...
#view
class VideoFileDetailView(DetailView):
model = VideoFile
def get_context_data(self, **kwargs):
context = super(VideoFileDetailView, self).get_context_data(**kwargs)
# context['rates'] = VideoRate.objects.filter(video=11, user=1)
return context
Here pk
is the id of a video, I need to get the rates of the selected video by the current user.
get_context_data()
we can get the request troughtself.request
, thanks it's working with that – Eldridgeeldritch