Hey harijay,

A little warning up front, im fairly new to django as well so if there is some issue with my response sorry in advance. "return HttpResponse()" actually returns just an HttpResponse object. If you are coming from ROR its functionality is not identical to render (which will render and return the response to the client immediately). All HttpResponse does is generate a class that can be returned to the django internals to be sent to the client.
def view_func1(request):
    if request.user.is_authenticated():
            return HttpResponse("Hello world")
        else:
            return authenticate_user(request)
               |
               |------> why is this return necessary ?
Since the call structure goes similar to this Django Internals -> view_func1 -> authenticate_user. That return is required so that the Django internals see the HttpResponse Class. Without this return all thats passed back to django is None.

Ben

harijay wrote:
Hi i have a question about django and I am afraid it is a slighty
academic question.

I am a newbie at django and I am trying to hand off control from one
view_func1 to another function ( test code below)

I am wondering why although the aunthenticate_user function i.e the
second function returns a HttpResponse object. I still need to add a
return to the calling line
i.e I dont understand why in the code below I need to say

return authenticate_user(request)

rather than just  authenticate_user(request) since this function does
return an HttpResponse object.
If I dont say return authenticate_user(request) , I get a view
function does not return an HttpResponse object error even though the
authenticate_user function is getting called.


Here is the code.
Thanks
harijay


from django.http import HttpResponse
from authenticate_user import authenticate_user

def view_func1(request):
    if request.user.is_authenticated():
            return HttpResponse("Hello world")
        else:
            return authenticate_user(request)
               |
               |------> why is this return necessary ?

#file authenticate_user
from django.http import HttpResponse

def authenticate_user(request):
     return HttpResponse("Future view function to handle
authentication")

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


Reply via email to