Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

358
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda