Django - accessing the RequestContext from within a custom filter

前端 未结 4 1974
花落未央
花落未央 2021-01-04 02:33

I\'ve got a filter currency, which takes a value in USD and converts it to a currency (either USD or GBP). The currency to convert to is stored in the session,

4条回答
  •  没有蜡笔的小新
    2021-01-04 02:41

    If you create a template tag instead of a filter, you are given the context to work with (which contains the request). http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#writing-custom-template-tags

提交回复
热议问题