Web Analytics Made Easy -
StatCounter Trying to extend html file in html file - CodingForum

Announcement

Collapse
No announcement yet.

Trying to extend html file in html file

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Trying to extend html file in html file

    I'm trying to extend my first HTML file. However when I visit the URL I get the "TemplateDoesNotExist" error.
    I don't understand why though. Would someone be so kind to look at what I did to see if they can spot my mistake ?

    1st HTML file called "mission.html" :

    Code:
    {% extends 'background.html' %}
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <link rel="import" href="background.html">
    
    </head>
    <body>
    <p>
    mission html content
    </p>
    {% block content %}
    {% endblock %}
    
    
    </body>
    </html>

    2nd HTML file called "background.html"
    Code:
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    
    </head>
    <body>
    {% block content %}
    <h1> this is the header in the background html file </h1>
    {% endblock %}
    </body>
    </html>

  • #2
    here's a screenshot of the way my files and directories are structured as well, in case that's helpful.
    https://imgur.com/a/9VyAI

    Comment


    • #3
      Try to check the path to your collection of templates in "settings.py", in the variable : TEMPLATE_DIRS = ...

      Then I'm not sure... but maybe you can put the path to '/fight/templates/fight/' in it..

      OR alternatively, you can try to put all your templates one level up, directly in the 'templates' directory..

      Comment


      • #4
        You should Apply These settings

        Code:
        TEMPLATE_DIRS = (
             os.path.join(SETTINGS_PATH, 'templates'),
        )
        Mean that Django will look at the templates from templates/ directory under your project.

        Assuming your Django project is located at /usr/lib/python2.5/site-packages/projectname/ then with your settings Django will look for the templates under /usr/lib/python2.5/site-packages/projectname/templates/

        So in that case we want to move our templates to be structured like this:

        /usr/lib/python2.5/site-packages/projectname/templates/template1.html /usr/lib/python2.5/site-packages/projectname/templates/template2.html /usr/lib/python2.5/site-packages/projectname/templates/template3.html
        ASP.Net Software Development

        Comment

        Working...
        X