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
class QueryList(list): | |
""" | |
A list of primary keys for a specified model which can act as a QuerySet | |
Takes a ``model`` keyword argument indicating which model the PKs are | |
associated with. | |
""" | |
def __init__(self, *args, **kwargs): | |
self.model = kwargs.pop('model') | |
super(QueryList, self).__init__(*args, **kwargs) |
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
class ViewManager(models.Manager): | |
def bulk_create(self, *args, **kwargs): | |
raise NotImplementedError | |
def create(self, *args, **kwargs): | |
raise NotImplementedError | |
def get_or_create(self, *args, **kwargs): | |
raise NotImplementedError |
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
class ChoiceList(list): | |
def __init__(self, *args, **kwargs): | |
self.choices = kwargs.pop('choices') | |
super(ChoiceList, self).__init__(*args, **kwargs) | |
def items(self): | |
return [(k, v) for k, v in self.choices if k in self] | |
class ChoiceArrayField(ArrayField): | |
def __init__(self, *args, **kwargs): |
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
{% load sniplates %} | |
{% load_widgets core="widgets.html" _soft=True %} | |
{% block content %} | |
{% include "included_widget.html" %} | |
{% endblock %} |
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.template.response import TemplateResponse | |
from django.views.generic import DetailView | |
from weasyprint import HTML | |
class PDFResponse(TemplateResponse): | |
@property | |
def rendered_content(self): | |
template = self.resolve_template(self.template_name) | |
context = self.resolve_context(self.context_data) |