jeudi 21 septembre 2017

How to add prefix in URL-name in Django?

Here's first url-file:

from blog import urls as blog_urls
    urlpatterns += [
        url(r'^blog/', include(blog_urls, app_name='blog', namespace='blog'))
    ]

And the second url-file (blog/urls.py):

urlpatterns = [
    url(r'^$', blog, name='main'),
    url(r'post/(?P<slug>[\w\-]+)/$', post, name='post'),
    url(r'category/(?P<category>[\w\-]+)/$', blog, name='category'),
]

As a result, my url-adresses are:

http://ift.tt/2xp7QLr || blog.mysite.com/post

But what I actually want is this:

http://ift.tt/2wIEwfz || mysite.com/blog/post

Cant you please help me accomplish this ?

Aucun commentaire:

Enregistrer un commentaire