Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

248
Views
Inverso para 'etiquetado' con argumentos '('',)' no encontrado. 1 patrón probado: ['^tag/(?P<slug>[-\w]+)/$']

Sigo recibiendo este mensaje de error:

Inverso para 'etiquetado' con argumentos '('',)' no encontrado. 1 patrón probado: ['\^tag/\(\?P(?P[^/]+)\[\-\\w\]\+\)/\$$']

al intentar cargar mi base.html, debido a una etiqueta de anclaje. He mirado otras publicaciones con el mismo problema, pero todavía no sé dónde me estoy equivocando.

vistas.py

 class TagIndexView(TagMixin, ListView): template_name = 'post/index.html' model = Post paginate_by = '10' context_object_name = 'posts' def get_queryset(self): return Post.objects.filter(tags__slug=self.kwargs.get('slug')) def tagged(request): return render(request, 'blog/tagged.html', {'title': 'Tagged'})

urls.py

 path(r'^tag/(?P<slug>[-\w]+)/$',TagIndexView.as_view, name='tagged')

base.html
La etiqueta de anclaje:

 <li class="list-group-item"><a href="{% url 'tagged' tag.slug %}">Tags</a></li>

Pero sigo recibiendo un NoReverseMatch. En la etiqueta de anclaje he probado "tag.slug", "tag.id", "tag.pk" y algunos otros.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

  1. Use re_path() en lugar de path() para expresiones regulares.

    Referencia: https://docs.djangoproject.com/en/3.2/topics/http/urls/#using-regular-expressions

  2. Use [-\w]* (0 o más) en lugar de [-\w]+ (1 o más) para permitir una cadena vacía ('',) .

  3. Llame a .as_view con .as_view() para crear la función de vista.

 # path(r'^tag/(?P<slug>[-\w]+)/$', TagIndexView.as_view, name='tagged') re_path(r'^tag/(?P<slug>[-\w]*)/$', TagIndexView.as_view(), name='tagged')
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!