简体   繁体   English

json请求上的Django URL

[英]Django urls on json request

When making a django request through json as, 当通过json作为django请求时,

 var info=id + "##" +name+"##"
 $.post("/supervise/activity/" + info ,[] ,
 function Handler(data,arr) 
  {

  } 

In urls.py 在urls.py中

  (r'^activity/(?P<info>\d+)/$, 'activity'),

In views, 在视图中

 def activity(request,info):
     print info

The request does not go through. 该请求未通过。 info is a string.How can this be resolved info是一个字符串。如何解决

Thanks.. 谢谢..

^activity/(?P<info>\\d+)/$ will only match something like 'activity/42/' and the number (in this case 42) will be info . ^activity/(?P<info>\\d+)/$只匹配'activity / 42 /'之类的数字,数字(在这种情况下为42)将是info

If you appended '##name##' to the url, it will not be recognized. 如果您在网址后附加“ ## name ##”,则不会被识别。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM