Django 1.6 OrderedDict retaining state across requests? or cacheing enabled by default?

前端 未结 1 1999
南笙
南笙 2021-01-27 06:21

I am using django 1.6.0. I am working on a web app with a client \"dashboard\". In the client dashboard there are tabs in the header of the base template. The tabs are dynami

相关标签:
1条回答
  • 2021-01-27 06:46

    This is doing exactly what you tell it. You've set pages to be a class attribute of ParentMixin, which means it will also be a class attribute of any view class you mix it in to. Class attributes are shared across all instances of the class within a process, and since a process lasts across many requests, the data will persist across those requests.

    You should always set attributes on self, which means doing it inside a method, in this case probably inside get_context_data. Django goes to some lengths to ensure that instance data is not shared in class-based views, but this does not apply to class-level data.

    0 讨论(0)
提交回复
热议问题