Question

I'm trying to set up the django-administration package. I have successfully isntalled it, ran manage.py syncdb and am now trying to set it up.

Under /home/ec2-user/srv/mysite/templates/, I have two files base.html and index.html.

I also have /registration/ that contains things like activate.html, logout.html, etc etc...

When I got to /accounts/register, I get:

Error during template rendering
In template /home/ec2-user/srv/mysite/templates/base.html, error at line 15
Reverse for 'index' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []

Here is my base.html

{% load i18n %}

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<head>
    <link rel="stylesheet" href="/style.css" />
    <title>{% block title %}User test{% endblock %}</title>
</head>

<body>
<div id="header">
    {% block header %}
    <a href="{% url 'index' %}">{% trans "Home" %}</a> |

    {% if user.is_authenticated %}
    {% trans "Logged in" %}: {{ user.username }}
    (<a href="{% url 'auth_logout' %}">{% trans "Log out" %}</a> |
    <a href="{% url 'auth_password_change' %}">{% trans "Change password" %}</a>)
    {% else %}
    <a href="{% url 'auth_login' %}">{% trans "Log in" %}</a>
    {% endif %}
    <hr />
    {% endblock %}
</div>

<div id="content">
    {% block content %}{% endblock %}
</div>

<div id="footer">
    {% block footer %}
    <hr />
    {% endblock %}
</div>
</body>

</html>

Here is my index.html

{% extends "base.html" %}
{% load i18n %}

{% block content %}
Index page
{% endblock %}

I'm new to Django so any help and explanations why this is happening would be much appreciated!

Edit 1 Here's urls.py for the main "mysite"

from django.conf.urls import patterns, include, url
from django.conf import settings

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    url(r'^', include(admin.site.urls)),
    url(r'^polls/', include('polls.urls',namespace = "polls")),
    url(r'^accounts/', include('registration.backends.default.urls')),
)

Also, here's the relevant section from Apache. Note that I only want to have django respond to a few suburls, that is why I have it like I do:

WSGIScriptAlias /polls /home/ec2-user/srv/mysite/apache/wsgi.py
WSGIScriptAlias /admin /home/ec2-user/srv/mysite/apache/wsgi.py
WSGIScriptAlias /accounts /home/ec2-user/srv/mysite/apache/wsgi.py
Was it helpful?

Solution

You mentioned in your comment you do not want an index/home page:

The reason I don't have "/" is because I don't want Django to respond to everything. Only very specific suburls....

So why don't you just remove the <a href="{% url 'index' %}">{% trans "Home" %}</a> | link? Did you want it to point somewhere else?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top