Get the sourcecode from a template name without rendering it

1
2
3
4
from django.template.loader import find_template_source

def get_template_source(template_name):
    return find_template_source(template_name)[0]

More like this

  1. Quickly create an admin interface for an app. by bartTC 2 years, 8 months ago
  2. Language-aware template inclusion by bartTC 4 years, 2 months ago
  3. Language aware cache decorator by bartTC 4 years ago
  4. Automagically import settings from installed applications by jezdez 5 years, 3 months ago
  5. Management command to list custom management commands by pbx 3 years, 11 months ago

Comments

(Forgotten your password?)