feat(projects): 新增Django综合案例示例代码及素材

This commit is contained in:
100gle
2022-08-10 16:15:39 +08:00
parent b4c2257308
commit 3bf65b2755
65 changed files with 1496 additions and 0 deletions

View 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 %}

View 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">&copy; 2022-Present 100gle & 少数派</p>
</footer>
</div>
<script type="text/javascript" src={% static "js/main.js" %}></script>
</body>
</html>

View 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%}

View 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 %}