How do I use Django templates without the rest of Django?

后端 未结 13 1085
天命终不由人
天命终不由人 2020-11-29 16:17

I want to use the Django template engine in my (Python) code, but I\'m not building a Django-based web site. How do I use it without having a settings.py file (and others)

13条回答
  •  情话喂你
    2020-11-29 17:05

    While running the manage.py shell:

    >>> from django import template   
    >>> t = template.Template('My name is {{ me }}.')   
    >>> c = template.Context({'me': 'ShuJi'})   
    >>> t.render(c)
    

提交回复
热议问题