B
B
blackbb2015-12-20 16:14:07
Django
blackbb, 2015-12-20 16:14:07

How to write in url.py correctly?

There are two functions. Both have a slug field, how do I get them both processed in url.py? Such an option as I have now processes only the top line. I understand why this happens, but here's how to make both functions work. They need to be without url like arenda/(?P[-\w]+)/$/.

url(r'^(?P<slug>[-\w]+)/$', Arenda.as_view()),
url(r'^(?P<slug>[-\w]+)/$', Sale.as_view()),

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Kitaev, 2015-12-20
@deliro

Hang on different urls.

url(r'^rent/(?P<slug>[-\w]+)/$', Arenda.as_view()),
url(r'^sale/(?P<slug>[-\w]+)/$', Sale.as_view()),

V
Vladimir, 2015-12-20
@vintello

does not
work until the first find. no further processing
if you want to merge two views - merge at the template level with context passing

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question