Re: object_list || didn't return an HttpResponse object

2007-04-03 Thread Forest Bond
On Tue, Apr 03, 2007 at 04:42:58PM -0700, TaMeR wrote:
> On Apr 3, 7:10 pm, Forest Bond <[EMAIL PROTECTED]> wrote:
> > The way your view is written, if the user is not authenticated, no
> > HttpResponse is returned (since no return statement is executed).  You
> > probably want to just raise Http404 in that case.
> I am not sure what you mean
> I have a HttpResponseRedirect if the user is not authenticated.
> This error happens with an authenticated user.
> If the user is not authenticated he/she gets redirected to the login
> page and that works fine.
> See:
> if not request.user.is_authenticated():
> return HttpResponseRedirect('/account/login/?next=%s' %
> request.path)

Oh, you're right.

But, all of your other code is also in that if block.  So if the user is
authenticated, the view doesn't return anything.

Looks like you just have an indentation problem.  Remember, Python code is
whitespace-sensitive.

-Forest


signature.asc
Description: Digital signature


Re: object_list || didn't return an HttpResponse object

2007-04-03 Thread TaMeR



On Apr 3, 7:10 pm, Forest Bond <[EMAIL PROTECTED]> wrote:
> On Tue, Apr 03, 2007 at 03:46:04PM -0700, TaMeR wrote:
> > This used to work and I must have done something to break the code.
> > The simple page view still works fine but the list view gives me this
> > error and I been through my code a million times and can't find
> > anything wrong with it.
>
> The way your view is written, if the user is not authenticated, no 
> HttpResponse
> is returned (since no return statement is executed).  You probably want to 
> just
> raise Http404 in that case.
>
> -Forest
>
>  signature.asc
> 1KDownload

I am not sure what you mean
I have a HttpResponseRedirect if the user is not authenticated.
This error happens with an authenticated user.
If the user is not authenticated he/she gets redirected to the login
page and that works fine.
See:
if not request.user.is_authenticated():
return HttpResponseRedirect('/account/login/?next=%s' %
request.path)


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: object_list || didn't return an HttpResponse object

2007-04-03 Thread Forest Bond
On Tue, Apr 03, 2007 at 03:46:04PM -0700, TaMeR wrote:
> This used to work and I must have done something to break the code.
> The simple page view still works fine but the list view gives me this
> error and I been through my code a million times and can't find
> anything wrong with it.

The way your view is written, if the user is not authenticated, no HttpResponse
is returned (since no return statement is executed).  You probably want to just
raise Http404 in that case.

-Forest


signature.asc
Description: Digital signature


object_list || didn't return an HttpResponse object

2007-04-03 Thread TaMeR


This used to work and I must have done something to break the code.
The simple page view still works fine but the list view gives me this
error and I been through my code a million times and can't find
anything wrong with it.

= ERROR =
ValueError at /bbauction/events_list/1/
The view bbauction.views.events_list didn't return an HttpResponse
object.
Request Method: GET
Request URL:http://127.0.0.1:8000/bbauction/events_list/1/
Exception Type: ValueError
Exception Value:The view bbauction.views.events_list didn't return
an HttpResponse object.
Exception Location: /usr/lib/python2.4/site-packages/django/core/
handlers/base.py in get_response, line 94

= VIEW CODE =
from django.confimport settings
from django.contrib.auth.models import User
from django.shortcuts   import render_to_response
from django.httpimport HttpResponseRedirect
from bbauction.models   import *

def events_list(request, pagination_id):
if not request.user.is_authenticated():
return HttpResponseRedirect('/account/login/?next=%s' %
request.path)

from django.views.generic.list_detail import object_list
#events = Event.objects.all().values('id', 'name', 'postcode',
'start', 'vehicle').order_by('-start')
events = Event.objects.all().order_by('-start')
if len(events) == 0:
return render_to_response('bbauction/events_list.html', {'sid':
settings.SITE_ID})
return object_list(request, events, paginate_by = 30, page =
pagination_id, template_name = 'bbauction/events_list.html',
extra_context={'sid': settings.SITE_ID})

= URL CODE =
urlpatterns = patterns('bbauction',
(r'^events_list/(?P(\d+))/$', 'views.events_list'),
(r'^event_view/(?P(\d+))/$', 'views.event_view'),
)

= THE END =

Thank you


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~--~~~~--~~--~--~---