Skip to content

Instantly share code, notes, and snippets.

@bencleary
Created January 13, 2018 20:35
Show Gist options
  • Select an option

  • Save bencleary/f6dba3d29db2bb10335b1bb6b680555a to your computer and use it in GitHub Desktop.

Select an option

Save bencleary/f6dba3d29db2bb10335b1bb6b680555a to your computer and use it in GitHub Desktop.
from django.views.generic.base import View
from django.http import HttpResponse
from .render import Render
class RenderPDF(Render):
params: dict = None
template: str = None
email: bool = False
to: str = None
class RenderPDFMixin(RenderPDF, View):
def get(self, request, *args, **kwargs):
if self.email is False:
### always add request object ###
self.params['request'] = request
return Render.render(self.template, self.params)
else:
### process email ####
return HttpResponse("Email")
from django.utils import timezone
from .models import *
from .mixins import RenderPDFMixin
class Pdf(RenderPDFMixin):
template = "pdf.html"
params = {
'today': timezone.now(),
'sales': Sales.objects.all(),
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment