V
V
Vitaly2016-11-12 10:34:56
Django
Vitaly, 2016-11-12 10:34:56

How to solve this problem with regular expressions?

Greetings.
There is a urls.py file

urlpatterns = [
    ...
    url(r'^last/', last_images, name='last_images'),
    url(r'(?P<slug>[-\w]+)/$', show_image, name='show_image'),
    url(r'(?P<slug>[-\w]+)/delete/$', delete_image, name='delete_image'),

]

And the problem is that when you go to an address like /myimage/delete/ , the first regular expression fires and displays an error. How can I solve this problem?
Swapping them around doesn't seem like the right thing to do.
Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Kuts, 2016-11-12
@MrCute

> Places to change them like it would not be entirely correct.
Why?
Swap them and don't fool around.

S
sim3x, 2016-11-12
@sim3x

r'^last/'
r'^last/$'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question