Skip to content

Instantly share code, notes, and snippets.

@dbwodlf3
Last active April 26, 2018 10:45
Show Gist options
  • Select an option

  • Save dbwodlf3/37cb8987891b025cac9d05e750a0f9ff to your computer and use it in GitHub Desktop.

Select an option

Save dbwodlf3/37cb8987891b025cac9d05e750a0f9ff to your computer and use it in GitHub Desktop.
Django Webpage Templates:: templates/webPage/
{% extends "webPage/layout.html" %}
{% block body %}
<h1>This Page is About!</h1>
{% endblock %}
{% extends "webPage/layout.html" %}
{% block body %}
<h1>This Page is Boards</h1>
<div class="container">
<table class="boardTable">
<tr>
<th>Title</th>
<th>Writer</th>
<th>Date</th>
<th>Views</th>
<th>id</th>
</tr>
{% for i in posts %}
<tr onclick="window.location='/webPage/board/viewer/{{i.id}}';">
<td>{{i.title}}</td>
<td>{{i.writer}}</td>
<td>{{i.updatedDate}}</td>
<td>{{i.views}}</td>
<td>{{i.id}}</td>
</tr>
{% endfor %}
</table>
<div id="pageMove" style="text-align:center;">
<input id="pageMover" type="text" style="width:50px;">
<span>
<b id = "maxPageNumber">/{{maxPageNumber}}</b>
</span>
</div>
</div>
<div id = "maxPageNumber" style="display:None;">{{maxPageNumber}}</div>
<style>
.container .boardTable{
width: 100%;
border-spacing: 0;
border: 1px solid #ddd;
}
span > b{
font-size: 24px;
}
.pageMove > .material-icons{
cursor:pointer;
}
</style>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons"
rel="stylesheet">
<script>
pageNumber = new URL(document.URL);
pageNumber = pageNumber.pathname.split("/")[3];
k = document.querySelector("#pageMover");
k.setAttribute("Value",pageNumber);
k.addEventListener("keyup", function(event) {
event.preventDefault();
if(event.keyCode == 13){
text = '/webPage/board/'+ event.target.value;
window.location.href = text;
}
});
</script>
{% endblock %}
{% extends "webPage/layout.html" %}
{% block body %}
<h1>This Page is Contact!</h1>
{% endblock %}
<form action="/webPage/editor/" method="post">
{% csrf_token %}
{{form.media}}
{{form.as_p}}
<input type="submit"/>
</form>
{% extends "webPage/layout.html" %}
{% block body %}
<h1>This Page is Home!</h1>
{% endblock %}
<form>
{{ form.media}}
{{ form.as_p}}
</form>
<form>
{{ form.media}}
{{ form.as_p}}
</form>
<!doctype html>
<html lang="ko">
<head>
<meta charset="utf-8"/>
<title>myFirstDjangoApp</title>
</head>
<nav>
<ul id = myNav>
<li><a href="/webPage/home/">Home</a></li>
<li><a href="/webPage/news/">News</a></li>
<li><a href="/webPage/contact/">Contact</a></li>
<li><a href="/webPage/about/">About</a></li>
<li><a href="/webPage/board/">Board</a></li>
</ul>
</nav>
<body>
<div style="margin-left:25%;padding:1px 16px;height:1000px;">
{% block body %}
{% endblock %}
</div>
</body>
</html>
<style>
body {
margin: 0;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
width: 25%;
background-color: #f1f1f1;
position: fixed;
height: 100%;
overflow: auto;
}
li a {
display: block;
color: #000;
padding: 8px 16px;
text-decoration: none;
}
li a.active {
background-color: #4CAF50;
color: white;
}
li a:hover:not(.active) {
background-color: #555;
color: white;
}
</style>
<script>
var temp = new URL(document.URL)
var myQuery="[href=\""
temp = temp.pathname.split("/")[2];
temp = "/webPage/" + temp + "/";
myQuery = myQuery + temp
myQuery = myQuery + "\"]"
document.querySelector(myQuery).className = "active"
</script>
{% extends "webPage/layout.html" %}
{% block body %}
<h1> This Page is News! </h1>
<table>
{% for Person in Presidents %}
{% if Person == "문재인" %}
<tr><th>
{{ Person }}
</th></tr>
{% endif %}
{% endfor %}
</table>
{% endblock %}
{% extends "webPage/layout.html" %}
{% block body %}
<h1>{{userPost.title}}</h1>
<div class = "content">
{% autoescape off %}
{{userPost.content}}
{% endautoescape%}
</div>
{% endblock %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment