I'm running the Django development web server (python manage.py runserver), and when I add a query string to a URL which is served by a view, the query string is removed from the URL in the browser. For example, when I visit http://127.0.0.1:8000/?test=y, the browser URL shows http://127.0.0.1:8000. The log, though shows the GET parameter:

[25/Aug/2018 11:18:41] "GET /?test=y HTTP/1.1" 200 8517

Here is my view:

def main_page(request):
  if request.method == 'POST':
    return login(request)
  elif request.user.is_authenticated():
    return redirect_user_main_page(request)
  else:
    return render(request, 'main_page2.html', {
      'next': request.GET.get('next'),
      })

and my URL:

  url(r'^$', main_page, name="main_page"),

The else: path is taken.

I observe this behavior on all browsers.

I also observe this behavior when I run the Django app behind Nginx and uWSGI.

I'm using Django 1.11.4.

comments

Subscribe to our newsletter. It's free!

© 2018 | Reza Sabir Hossain