2

I want to match the following url

 url(r'^home/Physician|Vendor/$, 'ViewerLog', name="monitor_viewerLog"),

How do I match Physician or Vendor? Is this the right way?

2 Answers 2

5

To match Physician or Vendor, use parentheses.

url(r'^home/(Physician|Vendor)/$, 'ViewerLog', name="monitor_viewerLog"),

This will call your view with the matched value as an argument. If you don't want to capture the matched value, use (?:...).

url(r'^home/(?:Physician|Vendor)/$, 'ViewerLog', name="monitor_viewerLog"),
Sign up to request clarification or add additional context in comments.

Comments

3

If you want to capture the matched value, you can name your returned argument:

url(r'^home/(?P<guy>Physician|Vendor)/$', 'ViewerLog', name="monitor_viewerLog"),

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.