Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

183
Views
Django url disspatcher matches the wrong regex

I have created the following urlpatters

urlpatterns=[
     url(r'(?P<user_name>[a-zA-Z]+)/$', views.profile_view, 
     kwargs=None, name='userprofile'),
     url(r'(?P<user_name>[a-zA-Z]+)/interests/$',views.interest,name='interests')

]

But when I enter the url localhost:8000/mainuser/interest/ it treat it as first url and opens profile_view. It is clearly matching '/'. Help me with this.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You should begin your URL patterns with the start of line character ^. Because you are not including this character the regex for the first pattern matches any URL that ends with 1 or more characters followed by a forward-slash.

urlpatterns=[
     url(r'^(?P<user_name>[a-zA-Z]+)/$', views.profile_view, kwargs=None, name='userprofile'),
     url(r'^(?P<user_name>[a-zAZ]+)/interests/$',views.interest,name='interests'),
]
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!