Sunday, August 5, 2012

Re: django.shortcuts redirect doesn't pass argument

On Sun, Aug 5, 2012 at 9:21 PM, forthfan <forthfan5155@gmail.com> wrote:

I'm trying to pass a filepath from one view to another by using 'redirect' from django.shortcuts, but the argument is not getting passed.  What am I doing wrong?

def upload1(request):
  if request.method == 'POST':
    form = UploadFileForm(request.POST, request.FILES)
    if form.is_valid():
      filepath = request.FILES['file']
      return redirect('/app/upload2/', filepath=filepath)

You are passing the hardcoded url to redirect, which will be used as-is (per doc: https://docs.djangoproject.com/en/1.4/topics/http/shortcuts/#redirect). If you want the filepath kwarg to be used to construct the url specified in the redirect, you need to pass the name of the view (or url pattern) for the view.

Karen
--
http://tracey.org/kmt/

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate