D
D
Domohod2022-01-06 15:36:35
Django
Domohod, 2022-01-06 15:36:35

Why are the links not working?

Making comments in Django using https://django-comments-xtd

I wrote get_absolute_url (as written in the documentation) so that errors do not occur, but they occur if you click on the preview button, delete, reply to a comment, etc. Only send works. Here is an example of the error:

TemplateDoesNotExist at /comments/reply/5/

models.py:

class Comment(models.Model):
    title = models.CharField(max_length=30, default="tit")

    def get_absolute_url(self):
        return reverse("comment")


urls: views.py:
path('info', Comment2.as_view(), name='comment'),

class Comment2(TemplateView):
    template_name = "registration/comments.html"

    def get_context_data(self, **kwargs):
        context = super(Comment2, self).get_context_data(**kwargs)
        comment = Comment.objects.get(pk=1)
        context['comment'] = comment
        return context

What is wrong? Have I spelled get_absolute_url correctly?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question