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.
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' %}