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

143
Visualizações
NoReverseMatch for Django and DjangoCMS App

I am trying to set up some URLs for tags and categories on a forum. The links look like this

<a href="{% url 'article-list-by-tag' %}{{ tag }}" class="badge badge-info" >{{ tag }}</a>

The URL pattern article-list-by-tag comes from a DjangoCMS app called AldrynNewsblog. It can be found HERE and looks like this

url(r'^tag/(?P<tag>\w[-\w]*)/',
    TagArticleList.as_view(), name='article-list-by-tag'),

Note that the NewsBlog does not have app_name declared in its urls.py.

The app itself is part of a larger Django app called DjangoCMS. The url entry-point for the latter is declared in project's main urls.py as follows:

path('', include('cms.urls')),

The error that I am getting is

Reverse for 'article-list-by-tag' not found. 'article-list-by-tag' is not a valid view function or pattern name.

What should I do to resolve this? I have tried adding namespace to various URL entries as well as app_name to NewsBlog to no avail. The Django version being used is 2.1

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

You need to pass the .slug of the tag as parameter of the URL, so:

<a href="{% url 'article-list-by-tag' tag=tag.slug %}" class="badge badge-info" >{{ tag }}</a>

If you import it with a namespace, you need to prefix the name of the view with that prefix, so 'some_namespace:article-list-by-tag'.

over 4 years ago · Santiago Trujillo Relatório

0

In case it helps anyone, the following code worked for my use-case:

<a href="{% namespace_url 'article-list-by-tag' tag=tag.slug %}" class="badge badge-info" >{{ tag }}</a>

Where the namespace_url is a template tag provided by DjangoCMS.

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