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

295
Visualizações
Getting "AttributeError: 'str' object has no attribute 'regex'" in Django urls.reverse

As in the title, I'm getting

AttributeError: 'str' object has no attribute 'regex'

I've seen many valid answers to this, but none of them applied to my code as they identified issues in the urls.py file. My issue is in the views.py file.

I get the exception when using reverse to generate a redirect URL:

HttpResponseRedirect(reverse('changetracker:detail', args))

When I use 'changetracker:detail' in other functions, I don't get the exception.

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I'm answering this to share knowledge as I didn't see this particular root cause identified already.

The problem turned out to be that I should be using a keyword argument 'args=args' to pass in URL arguments, not a positional argument:

HttpResponseRedirect(reverse('changetracker:detail', args=args))

Using the positional argument (position 2) caused reverse to use that argument as the URL list and thus raise the AttributeError.

about 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