Pass a GET parameter through the Django view

Asked

Viewed 1,019 times

0

i am trying to pass a parameter via GET in the URL through the Django backend, but I’m not getting it.

My url to the page I want to pass the parameter to is

url(r'^(?P<short_name>\w+)/schedule/$', schedule_views.schedule, name='schedule'),

And I wanted that right after I do things in the call view, it would render the page with the Schedule/? date=2018-03-01, for example.

I know I can get to GET through request.GET.get, but I would like to pass this parameter back to the front end.

Thank you!

1 answer

0


I think the solution would be for you to redirect already with the query string, something like:

from django.shortcuts import redirect

def schedule(request):

    # varios codigos

    return redirect(reverse('search_view') + '?date=2018-03-01')
  • Then in search_view I would have to put an argument in order to receive the date?

  • That depends on where you really want to get that date.

  • I managed to use using section variables! Thank you!

  • Show! If the answer was correct to solve the problem, can you mark it as correct? So other people who have the same problem will be able to find it more easily :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.