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

416
Visualizações
Django- Reverse for 'question_detail' with arguments '()' and keyword arguments '{}' not found

When I type the slug in to the url I can see the detail view of that post however, I can't redirect to the newly formed post when it saves into db. The post's are getting saved but on the redirect I keep getting NoReverseMatch Error.

Reverse for 'question_detail' with arguments '()' and keyword arguments '{}' not found. 1 pattern(s) tried: [u'(?i)question/(?P<slug>[\w\\-]+)/$']

I can't seem to crack it.

questions-url.py:

url(r'^(?P<slug>[\w\-]+)/$', QuestionDetailView.as_view(), name='question_detail')

views- redirect (after form saved) :

return reverse('questions:question_detail')

views - detail view

class QuestionDetailView(DetailView):
template_name = "questions/question_detail.html"
model = Question
slug_url_kwarg = 'slug'

models.py

def get_absolute_url(self):
    return reverse('questions:question_detail', kwargs={'slug':self.slug, 'question_id':self.id})
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

As the error says, the question_detail pattern expects a slug parameter but you are not passing one. You do so in your get_absolute_url method; you should do the same in your view.

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