I am trying to view Django classes (CBV).
class BlahView(TemplateView): template_name = 'blah/blah.html' def get_context_data(self, **kwargs):
Now I know that I can get request parameters from self.request. Now say that I want to analyze these query parameters and save them in the class. Can I save them in self.xxx ? Now, obviously, based on how classes work, this seems simple.
But I can't figure out the control flow by looking at the definition of View (superclass from TemplateView ). The source mentions as_view() as the "entry point"
I thought about setting my instance variables at the beginning of get_context_data() , but it doesn't seem to have the right to do initialization there.
Can I define __init__() for my CBV? If so, will there be problems with streams or something that can work with multiple instances of pages with a global instance of my analyzed data?
I know this sounds a bit messy, but I'm a little confused about the code stream in CBV.
python django django-class-based-views
ForeverLearnNeverMaster Jul 12 '12 at 9:20 2012-07-12 09:20
source share