[Answer]-How can i include my template from the static folder in django

1👍

 import os
 import sys

 PORJECT_ROOT = os.path.join(os.path.dirname(__file__),'..')
 sys.path.insert(0, os.path.join(PROJECT_ROOT,'static'))

0👍

Make sure that the folder is included in the TEMPLATE_DIRS setting (in settings.py).

0👍

Generally(by convention) template files folder is project_root_folder\templates folder, update TEMPLATE_DIRS in settings.py:

import os
PORJECT_ROOT = os.path.dirname(os.path.dirname(__file__))
TEMPLATE_DIRS = (
    os.path.join(PORJECT_ROOT, 'templates'),
)

While static store only javascript/css/images fiels.

That will make future develop and deploy easier.

0👍

BY default django checks in app/templates directory for a template match, or in the project_root/templates/. You should have the directory listed in the TEMPLATE_DIRS setting as others have stated.

👤eusid

Leave a comment