HttpResponseRedirect django + facebook
I have a form with two buttons. depending on the user the buttons are taken to a different url. view function:
friend_id = request.POST.get('selected_friend_id_list')
history = request.POST.get('statushistory')
if history:
print "dfgdfgdf"
return HttpResponseRedirect('../status/')
else:
return direct_to_template(request, 'friends_list.fbml',
extra_context={'fbuser': user,
'user_lastname':user_lastname,
'activemaintab':activemaintab,
'friends':friends,
'friend_list':friend_list})
for template:
<input type="submit" value="Calendar View" name="calendarview"/>
<input type="submit" value="Status History" name="statushistory"/>
</form
so my problem is that the page is not redirecting the url. If I create an HttpResponseRedirect ('../') it gives me the correct page but the url doesn't change.
current page = "friendlist / status / so after form submit my url should be frinedlist / list / so this should work HttpResponseRedirect ('../list/') but url doesn't change. Any ideas? How can I fix this thanks
a source to share
"so my problem is the page is not being redirected to the url. If I create an HttpResponseRedirect ('../') it gives me the correct page, but the url doesn't change."
In the "URL" section, I am assuming you mean "the URL displayed in the browser". It helps if your question is very accurate.
You must provide an absolute URL first. http://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpResponseRedirect
It's pretty clear from the standards (RFC 2616, section 14.30) that an absolute URL is required. Some browsers may wrap relative URLs. Some don't.
Second, you should never use a relative url in your programs.
You have to use reverse .
from django.core.urlresolvers import reverse
def myview(request):
theURL= reverse('path.to.viewFunction')
return HttpResponseRedirect(theURL)
a source to share