python - what is this url mean in django -


this code :

(r'^q/(?p<terminal_id>[^/]+)/(?p<cmd_type>[^/]+)/?$', 'send_query_cmd'), 

the view :

def send_query_cmd(request, terminal_id, cmd_type): 

waht ?p mean .

i dont know url mean ,

thanks

(?p<id>regexp) syntax python regular expression named group capturing. http://docs.python.org/library/re.html ->> scroll down (?p...

as p stands for.. parameter? python? origin sounds fun.

anyways, these same regular expressions django url resolver uses match url view, along capturing named groups arguments view function. http://docs.djangoproject.com/en/dev/topics/http/urls/#captured-parameters

the simplest example this:

(r'^view/(?p<post_number>\d+)/$', 'foofunc'),  # we're capturing simple regular expression \d+ (any digits) post_number  # passed on foofunc  def foofunc(request, post_number):     print post_number  # visiting /view/3 print 3.  

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -