Skip to content

Instantly share code, notes, and snippets.

@sonthonaxrk
Created January 2, 2015 11:26
Show Gist options
  • Save sonthonaxrk/e2d77ce62a7d05e962f5 to your computer and use it in GitHub Desktop.
Save sonthonaxrk/e2d77ce62a7d05e962f5 to your computer and use it in GitHub Desktop.
#urls.py
urlpatterns = patterns('',
url(r'^profile/$', login_required(views.BaseView.as_view(
template_name='profile_view.html' testVariable='testing' )), name='profile'),
)
#views.py
class BaseView(TemplateView):
testVariable = None
def dispatch(self, request, *args, **kwargs):
print(self.testVariable)
return super(BaseView, self).dispatch(request, *args, **kwargs)
def get_context_data(self, **kwargs):
return {'request' : self.request,
'user' : self.request.user }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment