Created
April 4, 2018 09:10
-
-
Save shrawanx/32ad1544fdca810c6bbe03961a86c553 to your computer and use it in GitHub Desktop.
Dynamically rendering custom templates tags from view to template in django
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
def home(request): | |
from django.template import Context | |
from django.template import Template | |
from django.template.loader import render_to_string | |
x = '{% load custom_tags %} {% user_count %}' | |
prepare = {'tags':x} | |
x = render_to_string('home.html',context=prepare,request=request) | |
template = Template(x) | |
context = Context({}) | |
y = template.render(context) | |
return HttpResponse(y) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment