what is reverse() in Django

前端 未结 7 1588
Happy的楠姐
Happy的楠姐 2020-11-30 16:40

When I read django code sometimes, I see in some templates reverse(). I am not quite sure what this is but it is used together with HttpResponseRedirect. How an

7条回答
  •  孤独总比滥情好
    2020-11-30 17:15

    There is a doc for that

    https://docs.djangoproject.com/en/dev/topics/http/urls/#reverse-resolution-of-urls

    it can be used to generate an URL for a given view

    main advantage is that you do not hard code routes in your code.

提交回复
热议问题