Skip to content

Instantly share code, notes, and snippets.

View CrazyChief's full-sized avatar

Dmitry Danilov CrazyChief

View GitHub Profile
@CrazyChief
CrazyChief / landing_views.py
Created March 6, 2019 14:11
Loads appropriate page with specified template and static files.
class LandingView(TemplateView):
def get(self, request, *args, **kwargs):
self.piece = request.META["PATH_INFO"].split('/')[2]
self.object = Landing.objects.get(slug__exact=self.piece)
self.template_name = self.object.get_template_path
return super(LandingView, self).get(request, *args, **kwargs)
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)