Django Class Based Views : Overriding View Class as_view and dispatch

Very often overriding dispatch or as_view comes as an easy method for toubleshooting issues with class based views. Here is a snippet showing this.

from django.shortcuts import render
from django.views.generic import View
from django.http import HttpResponse
from django.utils.decorators import classonlymethod

class SimpleView(View):
    def get(self, request):
       print('### SimpleView/get : request path = %s' % request.path)
       return HttpResponse(request.path)

    @classonlymethod
    def as_view(cls, **initkwargs):
        print('### SimpleView as_view')
        self = cls(**initkwargs)
        view = super(SimpleView, cls).as_view(**initkwargs)
        return view

    def dispatch(self, request, *args, **kwargs):
        print('### SimpleView / dispatch : %s' % request.method)
        return super(SimpleView, self).dispatch(request, *args, **kwargs)

Installing MAAS 1.8 on Ubuntu 14.04 LTS

Ubuntu 14.04  LTS  installs  maas-1.5 by default. The current mass version is 1.8  (as on  July 2015 ). However mass maintainers ppa  is available for  1.8 release of maas at  MAAS Maintainers PPA

Add the repository to sources

add-apt-repository ppa:maas-maintainers/stable
apt-get update

View available maas versions

apt-cache show maas | less
apt-cache show maas | grep Version

Install ( Simulate ) to see what gets installed

apt-get  -s install  maas  | grep Inst  | grep maas
apt-get  -s install  maas-dhcp  | grep Inst  | grep maas

Install maas server, DNS and DHCP

apt-get install maas maas-dhcp maas-dns