Skip to content

Instantly share code, notes, and snippets.

@pfigue
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pfigue/9068831 to your computer and use it in GitHub Desktop.
Save pfigue/9068831 to your computer and use it in GitHub Desktop.
Django Cheatsheet
from django.shortcuts import (render, redirect, )
from django.contrib.auth import logout as auth_logout
from django.contrib.auth.decorators import login_required
from django.http import HttpResponse
from django.contrib.auth.models import User
from django.utils.decorators import method_decorator
from django.views.decorators.csrf import csrf_exempt
from django.views.generic import (TemplateView, View, )
from django.core.exceptions import (ObjectDoesNotExist, MultipleObjectsReturned)


class MyView(TemplateView):
    @method_decorator(login_required)
    def get(


class MyTestCase(TestCase):
    def assertDictHasKey(self, dictionary, key):
        if not key in dictionary:
            raise AssertionError('Dictionary is missing key "%s"' % key)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment