0

When i access this url:

http://localhost:8000/ProjectOverview/proj_view/15/

Django tells me that the format is in complete:

Request Method:     GET
Request URL:    http://localhost:8000/ProjectOverview/proj_view/15/
Django Version:     1.3.1
Exception Type:     ValueError
Exception Value:    incomplete format

Exception Location:     /home/projects/bruens_erp/ProjectOverview/views.py in proj_view, line 11

My urls.py:

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

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    url(r'^ProjectOverview/$', 'ProjectOverview.views.index'),
    url(r'^ProjectOverview/login/$', 'ProjectOverview.views.login'),
    url(r'^ProjectOverview/proj_view/(?P<cust>\d+)/$', 'ProjectOverview.views.proj_view'),
    url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
    url(r'^admin/', include(admin.site.urls)),
)

My views.py:

# Create your views here.
from django.http import HttpResponse

def index(request):
    return HttpResponse("Index.... please login")

def login(request):
    return HttpResponse("login page")

def proj_view(request, cust):
    return HttpResponse("project overview for cust: %." % cust)

What is wrong with this code?

1 Answer 1

2

You need to make your % become %s (if it's an string) or %d (if it's an integer):

def proj_view(request, cust):
    return HttpResponse("project overview for cust: %s." % cust) 

See python string-formatting.

Sign up to request clarification or add additional context in comments.

1 Comment

Hmm yes, just saw the typo.. goddamn dyslexias

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.