开发者

Use first param in django URL

开发者 https://www.devze.com 2023-03-03 12:34 出处:网络
I开发者_如何学C want to to know if its possible to use the first \"segment\" of a Django URL as a parameter and what would that regex look like.

I开发者_如何学C want to to know if its possible to use the first "segment" of a Django URL as a parameter and what would that regex look like.

example:

(r'^blog/', include('blog.urls')),
url(r'^admin/', include(admin.site.urls)),
#### I want to use the following
(r'^THISISMYPARAM$, include("whatever")),

So then when someone visited http://example.com/SOMETHING I could use do something with that.

My regex keeps breaking my other urls :\


You can do something like this:

(r'^(?P<thisismyparam>\w+)$', include('whatever'))
0

精彩评论

暂无评论...
验证码 换一张
取 消