Skip to content
Switch branches/tags
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Django Class Based Views Inspector

Use the Django Class Based Views Inspector

What's a class based view anyway?

Django 1.3 came with class based generic views. These are really awesome, and very powerfully coded with mixins and base classes all over the shop. This means they're much more than just a couple of generic shortcuts, they also provide utilities which can be mixed in the much more complex views that you write yourself.

Great! So what's the point of the inspector?

All of this power comes at the expense of simplicity. Trying to work out exactly which method you need to customise on your UpdateView can feel a little like wading through spaghetti - it has 8 separate ancestors (plus object) spread across 3 different files. So working out that you wanted to tweak UpdateView.get_initial and what it's keyword arguments are is a bit of a faff.

That's where this comes in! Here's the manifesto:

Provide an easy interface to learning the awesomeness of class based views. It should offer at least the ability to view the MRO of a generic view, all of the methods which are available on a particular class (including all inherited methods) complete with signature and docstrings. Ideally you should then be able to see where that method has come from, and any super calls it's making should be identified. Wrap this all up in a shiny front end!

Tools to consider

  • Python's built in inspect module to work out what's going on and put it in the database
  • JQuery for shinyness
  • Backbone for JS structure
  • Piston for API
  • SASS/LESS and/or Bootstrap to make CSS less painful


First you should install some OS libraries required for some packages, this can vary with each OS, but if you're on Ubuntu 14.04, then this should do the trick for you:

sudo apt-get install python3-dev libmemcached-dev zlib1g-dev libpq-dev

After this, install as you normally would a Django site (requirements.txt provided).

e.g. (inside your virtualenv or whatever)

pip install -r requirements.txt

Prepare the database (assuming you've got required database)

python migrate cbv

Populate the database with fixtures, either all at once:

python load_all_django_versions

or one at a time, for example:

python loaddata cbv/fixtures/project.json

python loaddata cbv/fixtures/1.8.json
python loaddata cbv/fixtures/1.9.json

Collect static files (CSS & JS)

python collectstatic

Run server and play around

python runserver

Updating Requirements

Run pip-compile and requirements.txt will be updated based on the specs in

More details can be found on the pip-tools website.

Updating for New Versions of Django

The procedure for updating for a new version of Django is as simple as:

  1. Update the file to pin the required version of Django;
  2. Use pip-compile to freshen requirements for the new version of Django;
  3. Use pip-sync to update your virtual environment to match the newly compiled requirements.txt file;
  4. Update the project's code to run under the target version of Django, as necessary;
  5. Use python populate_cbv to introspect the running Django and populate the required objects in the database;
  6. Use python fetch_docs_urls to update the records in the database with the latest links to the Django documentation;
  7. Export the new Django version into a fixture with: python cbv_dumpversion x.xx > cbv/fixtures/x.xx.json;


All you should do is:

make test


License is BSD-2.


A documentation tool for getting your head around Django's class based views.




No releases published


No packages published