Sunday, August 5, 2012

Re: django.shortcuts redirect doesn't pass argument

My example is wrong, because filepath turns out to be an 'InMemoryUploadedFile' object.  But the problem remains the same because I had a dummy filename string that I was trying to pass.  Actually the file would be uploaded to the server to a local file in upload1, then the filepath of the local file needs to be passed to upload2.

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

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)

def upload2(request, filepath=None):
  if request.method == 'GET':
    if filepath:
    . . .

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/Bl7QVZZv7_MJ.
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.

--
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