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

160
Visualizações
Django wrong url?

I have two urls.One is for blogs and the other is for games.I have app for games and blogs.

path('',include('games.urls')),
   path('blog',include('blogs.urls')),

My gameapp url is like this:

path('<slug:platform>/<slug:slug>',views.oyun,name='detail'),

My blogapp urls are like this:

path('', views.blogs, name='blog'),
    path('/<slug:slug>', views.blog_id, name='blog_id'),

This url is going to(path('/<slug:slug>', views.blog_id, name='blog_id')), views.oyun so it is giving error. How can i solve this?

Views.py

def blogs(request):
    blogss=blog.objects.all().order_by('-created')
    return render(request,"blog.html",{"blogs":blogss})


def blog_id(request,slug):

    blog_id=blog.objects.get(seo_url=slug)



    return render(request,"blog-writings.html",{"blog_id":blog_id})

def oyun(request,platform,slug):
   oyun = Oyunlar.objects.get(slugyap=slug)


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

0

The detail path will capture the URLs that are supposed to fire the blog_id path. Indeed, in the games.urls we see:

path('<slug:platform>/<slug:slug>',views.oyun,name='detail'),

whereas for the blog_id, the complete URL path is:

     'blog/<slug:slug>'

This thus means that if you visit blog/foo, it will fire the oyun view with 'blog' as value for the platform variable, and 'foo' as value for the slug variable.

You can swap the paths, such that it will first inspect the items with a blog/ prefix, and only will fire the oyun view, if that is not the case:

urlpatterns = [
    path('blog',include('blogs.urls')),  # ← first the blog/ paths.
    path('',include('games.urls')),
]
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