Q
Q
question 12017-01-22 16:01:25
Django
question 1, 2017-01-22 16:01:25

Why doesn't url(django) work?

url in config

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^', include('blog.urls')),	
]

url in application
urlpatterns = [
  url(r'^post/(?P<id>\d+)/$', views.valpost, name='valpost'),
  url(r'^post/', views.detail, name='detail'),
  url(r'^post/(?P<id>\d+)/edit/$', views.post_update, name='update'),
]

url(r'^post/(?P\d+)/edit/$', views.post_update, name='update'), / displays the post page/
how to fix?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sim3x, 2017-01-22
@JsDev

You just misspelled the regex

# url(r'^post/', views.detail, name='detail'),
url(r'^post/$', views.detail, name='detail'),

For the future - in controversial cases, the url is triggered, the one that is above all.
Therefore, for such cases, they do this
url(r'^post/admin/', include('post_admin.urls')),
url(r'^post/', include('post.urls')),

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question