BiAiB
BiAiB

Reputation: 14152

django template: include a *relative* file but don't parse it

How can one include a file in a django template like {% include %} would, but without parsing the file's contents ?

I am aware of {% ssi %} but that last one would not accept relative paths and throws '[Didn't have permission to include file]' at me.

EDIT: this is NOT a duplicate of How can I tell Django templates not to parse a block containing code that looks like template tags? . As I commented here, I need a directive to include a whole file, not a directive to ignore a block inside a template.


Note: I'm trying to include angularJs templates which are in the project's directory, but the syntax conflicts with Django template

Upvotes: 1

Views: 929

Answers (1)

Aya
Aya

Reputation: 42040

If you don't want to have to modify the files you're including, it looks as if the only way to do this is with a custom template tag.

Fortunately, it looks as if someone else has already posted one called include_raw on djangosnippets.org, although it was written for an older version of Django, so you'll have to make some modifications along the lines of those mentioned in one of the comments below the snippet.

Upvotes: 3

Related Questions