Skip to content

Instantly share code, notes, and snippets.

@mdiener21
Created August 26, 2016 07:50
Show Gist options
  • Save mdiener21/c50b5ea88a7e382c632e560b57f0f6d2 to your computer and use it in GitHub Desktop.
Save mdiener21/c50b5ea88a7e382c632e560b57f0f6d2 to your computer and use it in GitHub Desktop.
Django base models and views
from django.db import models
class AppQueryset(models.QuerySet):
pass
class AppManager(models.Manager):
queryset_class = AppQuerySet
def get_queryset(self):
return self.queryset_class(self.model)
class AppModel(models.Model):
objects = AppManager()
class Meta:
abstract = True
...
from django.views import generic
class View(generic.View):
pass
class TemplateView(generic.TemplateView, View):
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment