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

362
Visualizações
Django Interchanging the urls by overiding regex part

When requesting[GET] 127.0.0.1:8000/restaurant/1 i get a clean json and 200 status code

urlpatterns = [

url(r'^restaurant',views.Restaurant_List_Create.as_view(), name='all_restaurants'),
url(r'^restaurant/(?P<pk>\d+)',views.Restaurant_Retrive.as_view(), name='specified_restaurant'),

]

but when i interchange the url codes it runs the views.Restaurant_List_Create.as_view() (overrides the regex url)

urlpatterns = [

url(r'^restaurant/(?P<pk>\d+)',views.Restaurant_Retrive.as_view(), name='specified_restaurant'),    
url(r'^restaurant',views.Restaurant_List_Create.as_view(), name='all_restaurants'),


]
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You url matches both because you don't have included $ sign at the end of your urls.

You can change them as follow :

urlpatterns = [
  url(r'^restaurant/(?P<pk>\d+)$',views.Restaurant_Retrive.as_view(), name='specified_restaurant'),    
  url(r'^restaurant$',views.Restaurant_List_Create.as_view(), name='all_restaurants'),
]
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