D
D
Dmitry Vyatkin2015-12-10 08:09:28
Django
Dmitry Vyatkin, 2015-12-10 08:09:28

How to get named arguments from url in django in generic views?

#urls.py
urlpatterns = patterns(
    "",
    url(r'^test/(?P<advert_id>[0-9]+)/$', views.EditTestView.as_view(), name='test'),
)
#view.py
class EditTestView(FormView):
    template_name = 'my/template.html'

It is necessary to make a request to the database, taking into account the parameter from the url. How to get this parameter in general views?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oscar Django, 2015-12-10
@winordie

self.kwargs.get('advert_id')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question