Created
August 26, 2016 07:50
-
-
Save mdiener21/c50b5ea88a7e382c632e560b57f0f6d2 to your computer and use it in GitHub Desktop.
Django base models and views
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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