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

134
Visualizações
What does it mean by object not reversible Django

I'm just trying to make a simple connection to another page using the url tag in Django. I'm getting a error of "'set' object is not reversible". After searching for a bit I've been unsuccessful in finding anything.

urls.py

from django.conf.urls import url
from . import views

APP_NAME = 'website'
urlpatterns = {
    url(r'^$', views.admin_view, name='adminview'),
    url(r'^eventview/$', views.event_view, name='eventview'),
}

admin_view.html

<!DOCTYPE html>
<html lang="en" >
<head>
{% load static %}
  {% block header%}
  {% include 'website/header.html' %}
  {% endblock %}

  <!-- Insert custom css here -->
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>

<!-- top navbar -->
  <nav class="navbar navbar-inverse navbar-fixed-top">
    <div class="container-fluid">

      <div class="navbar-header">
        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
          <span class="sr-only">Toggle navigation</span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
        <a class="navbar-brand" href="#">Vivid Fireworks</a>
      </div>

      <div id="navbar" class="navbar-collapse collapse">
        <ul class="nav navbar-nav navbar-right">
          <li><a href="{% url adminview %}">Dashboard</a></li>
          <li><a href="{% url eventview %}">Add Show</a></li>
          <li><a href="#">Settings</a></li>
          <li><a href="#">Profile</a></li>
          <li><a href="#">Help</a></li>
        </ul>
      </div>
    </div>
  </nav>

I haven't ran into this problem before and it seems like it'll be a simple fix just something I'm over looking. Any help is appreciated.

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

0

urlpatterns should be a list [...]. You currently have a set {...}. It should be:

urlpatterns = [
    url(r'^$', views.admin_view, name='adminview'),
    url(r'^eventview/$', views.event_view, name='eventview'),
]

In the template, you should use quotes when the url pattern name is a string:

{% url 'adminview' %}
{% url 'eventview' %}

If you want to use namespaces, then app_name should be lowercase.

app_name = 'website'
url_patterns = [
    ...
]

You then need to include the namespace when you use the url tag

{% url 'website:adminview' %}
{% url 'website:eventview' %}
about 4 years ago · Santiago Trujillo Relatório

0

  • **Change url to path if you have django version 2.0 **
about 4 years ago · Santiago Trujillo Relatório

0

in URLpatterns, make the change from {} to [] that will solve

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