Wednesday, June 24, 2015

Trying to do a 'return redirect' from one view to another (python 2.7.8, django1.7)

Here's an abbreviated look at some code I have:

@receiver(data_required)
def StartProcessView(sender, **kwargs):
    #print 'StartProcessView ENTERED !...'
    try:
        request = kwargs.get('request')
        postcopy = request.POST.copy()
        print'\n StartProcessView - THE "postcopy" OBJECT HAS BEEN GOTTEN!... \n'
        #print'\n StartProcessView - PREPARING TO REDIRECT THE REQUEST TO THE "FinishGetRequestUrlsView"!... \n'
        #return redirect('canvas_app/finishgetrequests/')
        #return redirect('/canvas_app/finishgetrequests/')
        return redirect('finishgettingrequests')
    except:
        print ' "StartProcessView" - Unexpected Error: ', str(sys.exc_info()[0])
        raise
  
def FinishGetRequestUrlsView(request):
    #print 'FinishGetRequestUrlsView ENTERED !...'
    try:
        print 'FinishGetRequestUrlsView READY!...'
    except:
        print ' "FinishGetRequestUrlsView" - Unexpected Error: ', str(sys.exc_info()[0])
        raise

I want to get the redirect working before finishing the rest of the code for both views, but I have yet to get it to work at all, even once. In the current example above I'm using the name of the view I want to redirect to, to call it with and it doesn't work(I also tried doing the redirects using urls on previous attempts, but have those statements commented out here.).

So I know I'm doing something wrong, but can't quite figure out where exactly my code is wrong.

I would appreciate any help that anyone can give me.
Thanks.

Henry
  

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a30ecab6-a4e0-4eb7-8d2e-fe8671c4484e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment