# Using Jinja2 but keeping the template directory as templates.

**URL:** <https://forum.djangoproject.com/t/using-jinja2-but-keeping-the-template-directory-as-templates/8199>\
**Category:** Templates & Frontend\
**Created:** [June 3, 2021, 1:50pm UTC](https://forum.djangoproject.com/t/using-jinja2-but-keeping-the-template-directory-as-templates/8199 "2021-06-03T13:50:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ultra-Instinct-05](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/ultra-instinct-05/32/3267_2.png) [@Ultra-Instinct-05](https://forum.djangoproject.com/u/Ultra-Instinct-05)\
**Post date:** [June 3, 2021, 1:50pm UTC](https://forum.djangoproject.com/t/using-jinja2-but-keeping-the-template-directory-as-templates/8199/1 "2021-06-03T13:50:48Z")

</div>

Hi everyone 👋

I want to use Jinja2 as the templating language for Django, but as per the docs, Django would look inside the `jinja2` subfolder in each registered app for templates. I don’t want that but want it to be the default `template` directory itself (which is the case for the Django’s default templating system). Any ideas ?

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [June 3, 2021, 2:58pm UTC](https://forum.djangoproject.com/t/using-jinja2-but-keeping-the-template-directory-as-templates/8199/2 "2021-06-03T14:58:58Z")

</div>

You could create a subclass of Jinja2, set the app\_dirname attribute on that class to “templates”, and use _that_ class as your template engine.

---

<div class="post-metadata">

**Author:** ![Ultra-Instinct-05](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/ultra-instinct-05/32/3267_2.png) [@Ultra-Instinct-05](https://forum.djangoproject.com/u/Ultra-Instinct-05)\
**Post date:** [June 4, 2021, 4:55am UTC](https://forum.djangoproject.com/t/using-jinja2-but-keeping-the-template-directory-as-templates/8199/3 "2021-06-04T04:55:11Z")

</div>

Is there an example in the docs about how I might go about this approach ?

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [June 4, 2021, 11:53am UTC](https://forum.djangoproject.com/t/using-jinja2-but-keeping-the-template-directory-as-templates/8199/4 "2021-06-04T11:53:23Z")

</div>

How, in Python, do you define a class that is a child of (inherits from) a parent class?

For a basic idea of what needs to be done, take a look at the source code for the Jinja2 class in django.template.backends.jinja2.

---

<div class="post-metadata">

**Author:** ![Ultra-Instinct-05](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/ultra-instinct-05/32/3267_2.png) [@Ultra-Instinct-05](https://forum.djangoproject.com/u/Ultra-Instinct-05)\
**Post date:** [June 7, 2021, 2:43pm UTC](https://forum.djangoproject.com/t/using-jinja2-but-keeping-the-template-directory-as-templates/8199/5 "2021-06-07T14:43:55Z")

</div>

Thanks for the help. Also based on the docs, [Templates | Django documentation | Django](https://docs.djangoproject.com/en/3.2/topics/templates/#configuration), in order to use Django specific tags in a Jinja2 environment, the docs tells about setting an `environment` option (which points to an environment function).

Could you tell what this option is ? Is it a setting we can set in `settings.py` ?

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [June 7, 2021, 2:53pm UTC](https://forum.djangoproject.com/t/using-jinja2-but-keeping-the-template-directory-as-templates/8199/6 "2021-06-07T14:53:55Z")

</div>

Sorry, I’ve never used Jinja2 - if the information available in [the Jinja2 class docs](https://docs.djangoproject.com/en/3.2/topics/templates/#django.template.backends.jinja2.Jinja2) doesn’t give you enough to start with, I’m not sure I can be of any help here.

Hopefully someone else reading this thread can jump in with some information.

---

<div class="post-metadata">

**Author:** ![Ultra-Instinct-05](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/ultra-instinct-05/32/3267_2.png) [@Ultra-Instinct-05](https://forum.djangoproject.com/u/Ultra-Instinct-05)\
**Post date:** [June 7, 2021, 4:27pm UTC](https://forum.djangoproject.com/t/using-jinja2-but-keeping-the-template-directory-as-templates/8199/7 "2021-06-07T16:27:51Z")

</div>

Thanks a lot. The `environment` option is defined in the `OPTIONS` list for the template backend (It just was buried among other details). I am now able to configure Jinja2 properly.
