Created — forked from vdboor/mixins.py

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Django view initialization ordering issues

View mixins.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
class BaseViewMixin(object):
def dispatch(self, request, *args, **kwargs):
# Set earlier to ensure that other class methods which expect
# these values to be present can be called in `init`
self.request = request
self.args = args
self.kwargs = kwargs
 
# Run the complete request, returning a response, but allowing
# `init` to either raise exceptions, or hijack the response if
# necessary.
return self.init() or super(BaseViewMixin, self).dispatch(request, *args, **kwargs)
 
def init(self):
# Hook to override in subclasses
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.