feat(projects): 新增Django综合案例示例代码及素材
This commit is contained in:
24
projects/web-django/todolist/templates/about.html
Normal file
24
projects/web-django/todolist/templates/about.html
Normal file
@@ -0,0 +1,24 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}
|
||||
{{ title }}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<article class="about">
|
||||
<h1>{{ header }}</h1>
|
||||
<section>
|
||||
<p>
|
||||
{% for content in about_content %}
|
||||
{{ content }} <br />
|
||||
{% endfor %}
|
||||
</p>
|
||||
<ul>
|
||||
{% for item in items %}
|
||||
<li>{{ item.0 }}:{{ item.1 }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</section>
|
||||
</article>
|
||||
{% endblock %}
|
||||
44
projects/web-django/todolist/templates/base.html
Normal file
44
projects/web-django/todolist/templates/base.html
Normal file
@@ -0,0 +1,44 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>
|
||||
{% if title == "home" %}
|
||||
Todolist Web App
|
||||
{% else %}
|
||||
Todolist Web App - {% block title %}{% endblock %}
|
||||
{% endif %}
|
||||
</title>
|
||||
{% load static %}
|
||||
<link rel="stylesheet" href={% static "css/simple-v1.min.css" %}>
|
||||
<link rel="stylesheet" href={% static "css/style.css" %}>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container">
|
||||
<nav class="navbar">
|
||||
<ul>
|
||||
<li>
|
||||
<a href="https://sspai.com" class="logo">
|
||||
<img src={% static "images/sspai-logo-light.svg" %} alt="logo">
|
||||
</a>
|
||||
</li>
|
||||
<li><a href={% url "index" %}>Home</a></li>
|
||||
<li><a href={% url "tasks" %}>Task</a></li>
|
||||
<li><a href={% url "about" %}>About</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
<hr />
|
||||
<main>
|
||||
{% block content %}
|
||||
{% endblock %}
|
||||
</main>
|
||||
<footer id="footer">
|
||||
<p class="copyright">© 2022-Present 100gle & 少数派</p>
|
||||
</footer>
|
||||
</div>
|
||||
<script type="text/javascript" src={% static "js/main.js" %}></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
19
projects/web-django/todolist/templates/index.html
Normal file
19
projects/web-django/todolist/templates/index.html
Normal file
@@ -0,0 +1,19 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}
|
||||
{{ title }}
|
||||
{% endblock %}
|
||||
|
||||
{% block content%}
|
||||
|
||||
<article class="content">
|
||||
<h1>🗣 <i>Hello, world</i></h1>
|
||||
<section>
|
||||
<p>{{ welcome }}</p>
|
||||
<p>
|
||||
{{ index_content }}
|
||||
</p>
|
||||
|
||||
</section>
|
||||
</article>
|
||||
|
||||
{% endblock%}
|
||||
96
projects/web-django/todolist/templates/tasks.html
Normal file
96
projects/web-django/todolist/templates/tasks.html
Normal file
@@ -0,0 +1,96 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title%}
|
||||
{{ title }}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="data-table">
|
||||
<h1>Tasks</h1>
|
||||
{% if not tasks %}
|
||||
<p>🤔 Whoops……似乎任务都做完了?那么可以点击下方的按钮添加任务!</p>
|
||||
{% else %}
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
{% for field in fields %}
|
||||
<th>{{ field }}</th>
|
||||
{% endfor%}
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for task in tasks %}
|
||||
<tr>
|
||||
<td>{{ task.id }}</td>
|
||||
<td>{{ task.name }}</td>
|
||||
<td>
|
||||
{% if task.priority == 1 %}
|
||||
{{ "一般" }}
|
||||
{% elif task.priority == 2 %}
|
||||
{{ "优先" }}
|
||||
{% else %}
|
||||
{{ "紧急" }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="task-decs">{{ task.description }}</td>
|
||||
<td class="task-status">
|
||||
{% if task.is_done %}
|
||||
{{ "已完成" }}
|
||||
{% else %}
|
||||
{{ "未完成" }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ task.group.name }}</td>
|
||||
<td>
|
||||
<div class="ops">
|
||||
<span>
|
||||
<a href="/tasks/update/{{task.id}}">更新</a>
|
||||
</span>
|
||||
<span>
|
||||
<a href="/tasks/delete/{{task.id}}">删除</a>
|
||||
</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="btn-add-task">
|
||||
<button>+</button>
|
||||
</div>
|
||||
<div class="task-form">
|
||||
<form action={% url "create_task" %} method="post" class="form">
|
||||
{% csrf_token %}
|
||||
<div>
|
||||
<label for="taskName">任务名称:</label>
|
||||
<input type="text" name="taskName" id="taskName" placeholder="请输入待办事项名称" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="taskPriority">优先级:</label>
|
||||
<select name="taskPriority" id="taskPriority">
|
||||
<option value="1" selected>一般</option>
|
||||
<option value="2">优先</option>
|
||||
<option value="3">紧急</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label for="taskGroup"> 分组: </label>
|
||||
<select name="taskGroup" id="taskGroup">
|
||||
{% for group in groups %}
|
||||
<option value="{{ group.id }}">{{ group.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label for="task-textarea">任务备注:</label>
|
||||
<textarea name="taskDescription" id="task-textarea" rows="5" placeholder="备注内容(可选)"></textarea>
|
||||
</div>
|
||||
<div class="btn-submit">
|
||||
<input type="submit" value="添加" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user