python - How to add my own html template in django -


i new in django, problem how give link css , js

{% load staticfiles %} <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">   <html xmlns="http://www.w3.org/1999/xhtml">      <head>      <meta http-equiv="content-type" content="text/html; charset=utf-8" />      <title>welcome</title>         <link href="css/templatemo_style.css" rel="stylesheet" type="text/css" />      <link rel="stylesheet" type="text/css" href="{% static "css/templatemo_style.css" %}" />      <script type="text/javascript" src="js/jquery.min.js"></script> 

css , js not load actual path, dont know how use actual path of static folder in html trying use

import os #dirname = os.path.abspath(os.path.dirname(__file__)) dirname = os.path.dirname(__file__) 

but give me wrong path

i providing brief description:

template_dirs = ( os.path.join(dirname, 'static/'), } 

my url

http://127.0.0.1:8000/blog/home/ 

error showing

template-loader postmortem  django tried loading these templates, in order:  using loader django.template.loaders.filesystem.loader:     d:\eclipse_jee_new_workspace\testing\testing\static\index.html (file not exist) using loader django.template.loaders.app_directories.loader:     c:\python27\lib\site-packages\django\contrib\auth\templates\index.html (file not exist)     c:\python27\lib\site-packages\django\contrib\admin\templates\index.html (file not exist) 

it showing:

d:\eclipse_jee_new_workspace\testing\testing\static\index.html 

but actual

if moved static folder in testing folder, me html page without css , js link

d:\eclipse_jee_new_workspace\testing\static\index.html 

sorry more description before situation is:

when page load css link give me error 404 same position index.html page load
how include css/js?
in current situation, using
{% include 'header.html' %}
include in index.html

template files should go in templates folder. , dirname has path settings.py.

should like:

dirname = os.path.join(os.path.dirname(__file__), '..') template_dirs = (     os.path.join(dirname, 'templates/'), } 

and make sure index.html in templates folder.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -