Mustack
Mustack

Reputation: 41

Django 1.2 won't run my view

I'm getting a 404 from my Django server even though it's aware of my view code. If I purposely misspelled the name of the view function, Django complains, so I know it's looking in the right place and that it is aware of this function.

My urls.py entry looks like this

url(r"^pdfgen/$", 'apps.pdfgen.views.pdfgen'),

And my view code is this

def pdfgen(request):
    html = "<html><body>This is a test.</body></html>"
    return HttpResponse(html)

So why is it that Django 404's when I visit localhost:xxxx/pdfgen/ ?

Upvotes: 0

Views: 66

Answers (1)

Alasdair
Alasdair

Reputation: 309089

If I purposely misspelled the name of the view function, Django complains, so I know it's looking in the right place and that it is aware of this function.

That doesn't mean that your request is hitting the correct view - it just means that Django can't load your url conf when you include views that don't exist. To be sure that Django is running the view you think it is, you need to add some logging or print statements to the view, or raise an exception in it.

Update your question to include all your url patterns. Your request is probably matching a view further up, which is returning the 404.

Upvotes: 1

Related Questions