heres my code, but still its not working:
from django.http import HttpResponse, Http404
from django.contrib.auth.models import User
from django.template import Context
from django.template.loader import get_template
def main_page(request):
template = get_template('main_page.html')
variables = Context({
'head_title': 'Django Bookmarks',
'page_title': 'Welcome to Django Bookmarks',
'page_body': 'Where you can store and share bookmarks!'
})
output = template.render(variables)
return HttpResponse(output)
def user_page(request, username):
try:
user = User.objects.get(username=username)
except:
raise Http404('Requested user not found.')
bookmarks = user.bookmark_set.all()
template = get_template('user_page.html')
variables = Context({
'username': username,
'bookmarks': bookmarks
})
output = template.render(variables)
return HttpResponse(output)
On Sun, Mar 7, 2010 at 11:19 PM, Daniel Roseman <[email protected]>wrote:
> On Mar 7, 2:42 pm, Naveen Reddy <[email protected]> wrote:
> > Why am i getting this error:
> > ValueError at /user/naveen_admin/
> > The view django_bookmarks.bookmarks.views.user_page didn't return an
> > HttpResponse object.
> > Request Method: GET
> > Request URL: http://localhost:8000/user/naveen_admin/
> > Exception Type: ValueError
> > Exception Value:
> > The view django_bookmarks.bookmarks.views.user_page didn't return an
> > HttpResponse object.
> > Exception Location:
> C:\Python26\lib\site-packages\django\core\handlers
> > \base.py in get_response, line 109
> > Python Executable: C:\Python26\python.exe
> > Python Version: 2.6.4
> > Python Path: ['D:\\django_workspace\\django_bookmarks', 'C:\
> > \Python26', 'C:\\WINDOWS\\system32\\python26.zip', 'C:\\Python26\
> > \DLLs', 'C:\\Python26\\lib', 'C:\\Python26\\lib\\plat-win', 'C:\
> > \Python26\\lib\\lib-tk', 'C:\\Python26\\lib\\site-packages']
> > Server time: Sun, 7 Mar 2010 20:07:27 +0530
> >
> > Here's my views code:
> > from django.http import HttpResponse, Http404
> > from django.contrib.auth.models import User
> > from django.template import Context
> > from django.template.loader import get_template
> >
> > def main_page(request):
> > template = get_template('main_page.html')
> > variables = Context({
> > 'head_title': 'Django Bookmarks',
> > 'page_title': 'Welcome to Django Bookmarks',
> > 'page_body': 'Where you can store and share bookmarks!'
> > })
> > output = template.render(variables)
> > return HttpResponse(output)
> >
> > def user_page(request, username):
> > try:
> > user = User.objects.get(username=username)
> > except:
> > raise Http404('Requested user not found.')
> > bookmarks = user.bookmark_set.all()
> > template = get_template('user_page.html')
> > variables = Context({
> > 'username': username,
> > 'bookmarks': bookmarks
> > })
> > output = template.render(variables)
> > return HttpResponse(output)
> > Please guide me through this. I am absolute beginner to django. Thaks
> > in advance
>
> Looks like an indentation problem in user_page. The lines after 'raise
> Http404` should be one indentation level to the left.
>
> If you don't understand this, you'll need to follow a beginner's
> Python tutorial.
> --
> DR.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<django-users%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>
--
Pain is temporary. It may last a minute, or an hour, or a day, or a year,
but eventually it will subside and something else will take its place. But,
quitting, however, lasts forever.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.