N
N
nihi1ist2021-07-26 09:15:59
Django
nihi1ist, 2021-07-26 09:15:59

How can I find a bug in Django code?

I started learning Django from the book by V.A. Dronova. I ran into an error that I can't find. Namely, the link to the section is not formed. There is a function:

def by_rubric(request, rubric_id):
    bbs = Bb.objects.filter(rubric=rubric_id)
    rubrics = Rubric.objects.all()
    current_rubric = Rubric.objects.get(pk=rubric_id)
    context = {'bbs': bbs, 'rubrics': rubrics, 'current_rubric': current_rubric}
    return render(request, 'bboard/by_rubric.html', context)

There is also a link that refers to this function:
urlpatterns = [
    path('<int:rubric_id>/', by_rubric),
    path('', index),
]

Tell me, where did I go wrong?

In case the error is in some other section of the code, here is a link to all the files.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Melnikov, 2021-07-26
@nihi1ist

{% for rubric in rubrics %}
<a href="/bboard/{{ rubrik.pk }}/">{{ rubric.name }}</a>

rubric != rubrik Misspelled
letter

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question