E
E
Egor L2021-02-08 23:29:27
Django
Egor L, 2021-02-08 23:29:27

How to pass data in django listview urlpatterns link?

How to pass data in link to listview?

ursl.py

urlpatterns = [
        path('test/<str:data>/', TestView.as_view(), name='test'),
    ]


view.py

class TestView(ListView):
    model = Test
    template_name = 'test/test.html'
    context_object_name = 'test'


how to get data data in TestView class?
I understand that through self.kwargs, but I can't figure out how

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2021-02-09
@bacon

Well, learn to debug, see what you get in self.kwargs, do the same print. Well, there is a suspicion that you are not doing exactly that, what kind of data is this?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question