S
S
Sergey Nizhny Novgorod2016-06-25 16:51:05
Django
Sergey Nizhny Novgorod, 2016-06-25 16:51:05

How to select a specific comment on a page?

Now I'm making a like button on the comments in the article.
Situation:
An article model - a model with comments is attached to it via ForeignKey.
In the view, it's all output like this:

def video(request, video_id):
    videoitem = Video.objects.get(id = video_id) #контент статьи
    comview = Video_com.objects.filter(video_link_id=video_id) #комментарии к статье выводятся на страницу через цикл

context = {
        "videoitem" : videoitem,        
        "comview" : comview,        
    }
    return render(request, 'faceset/videopage.html', context)

url to add likes to comments
url(r'^upvideocomlike(?P<add_id>[0-9]+)$', views.upvideocomlike, name='upvideocomlike'),
    url(r'^downvideocomlike(?P<add_id>[0-9]+)$', views.downvideocomlike, name='downvideocomlike'),

And I want to put a link to likes in a comment like this {% 'upvideocomlike' add_id %}, but I don't understand how to select a specific comment in a specific article? After all, in the url you need to somehow transfer both the number of the current article and the number of a specific comment.
Can you suggest the logic, I'm running something.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Nizhny Novgorod, 2016-06-27
@Terras

Oscar Django
example:
there is video.id = 1, it has two comments (id=1, id=2),
there is video.id = 2, it has three comments (id=3, id=4, id=5).
You just need to pass only the comment id, because all comments are stored in the same table and they cannot have the same id, regardless of which video they belong to

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question