KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I trying out Django's class based views (CBVs). class BlahView(TemplateView): template_name = 'blah/blah.html' def get_context_data(self, **kwargs): #code... def get(self, request, **kwargs): #more code... Now, I know that I can get the request params from self.request. Now say I want to parse these request params and store them within the class. Can I store those in self.xxx ? Now, obviously based on how classes work, this seems straightforward. But I can't make out the flow of control, looking at the definition of View (superclass of TemplateView ). The source mentions as_view() to be the 'entry-point' I thought of setting my instance variables at the beginning of get_context_data() but that doesn't seem right to do initialization there. Can I define an __init__() for my CBV? If so, will there be threading issues or something where multiple page-accesses possibly work with a global instance of my parsed data? I know this sounds a bit messy, but I'm just a bit confused with the code flow in CBVs.
Tags (comma-separated)
Save Edits
Cancel