Including a querystring in a django.core.urlresolvers reverse() call

后端 未结 5 810
一个人的身影
一个人的身影 2021-02-01 12:58

I\'m trying to reverse a named URL and include a querystring in it. Basically, I\'ve modified the login function, and I want to send ?next= in it.

Here\'s w

5条回答
  •  长情又很酷
    2021-02-01 13:29

    You can't capture GET parameters in the url confs, so your method is correct.

    I generally prefer string formatting but it's the same thing.
    "%s?next=%s" % (reverse(name), reverse(redirect))

    http://docs.djangoproject.com/en/dev/topics/http/urls/#what-the-urlconf-searches-against

    The URLconf searches against the requested URL, as a normal Python string. This does not include GET or POST parameters, or the domain name.

提交回复
热议问题