Eiður Geir Vilhelmsson Eiður Geir Vilhelmsson - 1 month ago 6x
Python Question

Reverse for 'guestbook.posts' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []

I keep getting this error and I've spent hours trying to figure out what is wrong with my code.

Here are my files:


from django.shortcuts import render
from django.http import HttpResponse
from django.template import RequestContext, loader
from django.utils import timezone

from guestbook.models import Post

# Create your views here.
def posts(request):
if (request.POST.get('name', 0)):
name = request.POST['name']
text = request.POST['text']
title = request.POST['titile']
p = Post(name=name, title=title, text=text, pub_date=timezone.now())
newest = Post.objects.order_by('-pub_date')[:5]
template = loader.get_template('guestbook/index.html')
context = RequestContext(request, {
'newest_post': newest,
'kalli': 543
return HttpResponse(template.render(context))

def write(request):
return render(request, 'guestbook/form.html')


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

from guestbook import views

urlpatterns = patterns('',
url(r'^$', views.posts, name='posts'),
url(r'^write', views.write, name='writer'),


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

from django.contrib import admin

urlpatterns = patterns('',
url(r'^polls/', include('polls.urls', namespace="polls")),
url(r'^guestbook/', include('guestbook.urls', namespace="guestbook")),
url(r'^admin/', include(admin.site.urls)),

My error is somewhere in this file, But I put in other codes in the question just in case,

NoReverseMatch at /guestbook/write

Reverse for 'guestbook.posts' with arguments '()' and keyword
arguments '{}' not found. 0 pattern(s) tried: []

Request Method: GET Request URL:
localhost:8000/guestbook/write Django Version: 1.6.6
Exception Type: NoReverseMatch Exception Value:

Reverse for 'guestbook.posts' with arguments '()' and keyword
arguments '{}' not found. 0 pattern(s) tried: []

Exception Location:
c:\python33\lib\site-packages\django\core\urlresolvers.py in
_reverse_with_prefix, line 456 Python Executable: c:\python33\python.exe Python Version: 3.3.5

The above is my Error.


What's you name?<br>
<form action="{% url 'guestbook.posts' %}" method="post">
{% csrf_token %}
<input type="text" name="name">
<input type="text" name="title">
<textarea rows=15 cols=100 name="text">
<input type="submit" value="Send post">


To reverse namespaced URLs, you'll need to refer to them as guestbook:posts rather than guestbook.posts, per the documentation.