python - Django URL regex matches correctly with GET but not POST -


i'm working on webapp let's poll django backend irc logs on given date. url structure is:

example.tld/weblogs/<example channel>/dl/<example date>.<example format>

users able query following url scheme:

example.tld/weblogs/<example channel>/

to last 100 lines of irc data well.

my url matching file correctly routes proper view (views.download) when request explicit get, unable post on example.tld/weblogs/<example channel>/dl/ , have post'ed form data sent same view explicit will.

for example, if user types explicit url example.tld/weblogs/foo/dl/2015-01-01.json request routed right view. however, if form submits post example.tld/weblogs/foo/dl/, post request sent view handles requests example.tld/weblogs/foo (in case).

project urls.py:

from django.conf.urls import include, url django.contrib import admin log import views  urlpatterns = [     url(r'^admin/', include(admin.site.urls)),     url(r'^weblog/', include('log.urls')), ] 

log.urls:

from django.conf.urls import url . import views  urlpatterns = [     url(r'^$', views.weblogs, name='weblogs'),     url(r'^(?p<channel>[^, ]{1,200})/$', views.channel, name="channel"),     url(r'^(?p<channel>[^, ]{1,200})/dl/(?p<date>[0-9]{4}-[0-9]{2}-[0-9]{2}).(?p<format>(html|json|yaml|xml))', views.download), ] 

the requests this:

"get /weblog/example/dl/2015-08-20.yaml/ http/1.1" 200 4621

the post requests this:

"post /weblog/example/dl/ http/1.1" 200 74

in regex, [^, ] matching character except commas , spaces, including forward slashes.

to exclude forward slashes, change [^,/ ]. alternatively, [-\w] + might appropriate.


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -