Using External HTML files in Django

276 views
Skip to first unread message

Santhosh sridhar

unread,
May 2, 2022, 3:15:34 PM5/2/22
to Django users
Hi,

I have few html files which are not part of my django project templates directory. 
I want to render these html files as a response into some url.

Could someone help if you have any idea?

I tried using {% include %} and it gave TemplateDoesNotExist error. 

-Santhosh

Hazho Human

unread,
May 2, 2022, 7:58:45 PM5/2/22
to django...@googlegroups.com
Why not serving that specific URL with Nginx or Apache?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/470e1ec2-58c3-4682-8698-7e7afe258c37n%40googlegroups.com.

Mike Dewhirst

unread,
May 3, 2022, 12:02:26 AM5/3/22
to django...@googlegroups.com, Hazho Human
On 3/05/2022 8:44 am, Hazho Human wrote:
Why not serving that specific URL with Nginx or Apache?

On Tue, 3 May 2022 at 03:15, Santhosh sridhar <santhos...@gmail.com> wrote:
Hi,

I have few html files which are not part of my django project templates directory. 
I want to render these html files as a response into some url.

Could someone help if you have any idea?

I tried using {% include %} and it gave TemplateDoesNotExist error.

In your settings file try naming the directory where the html files exist so that Django's template engine knows to look there.

TEMPLATES = [
    ...
    {
        ...
        "DIRS":  ["./path/to/templates", "./path/to/htmlfiles", ...],
        ...
    },
]

Don't know if that will work if the html files are outside your project scope and there will be permissions to consider etc


-Santhosh
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/470e1ec2-58c3-4682-8698-7e7afe258c37n%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAAtm9hvOd44zihVirJ2P0LyL6F1LW-2ikn01G8QOBQBcb3RjsQ%40mail.gmail.com.


-- 
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.
OpenPGP_signature

Santhosh sridhar

unread,
May 4, 2022, 2:31:21 AM5/4/22
to Django users
Thanks Mike. It worked !
Reply all
Reply to author
Forward
0 new messages