Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

191
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda