1 回答
TA贡献1816条经验 获得超6个赞
Django 基本上遵循 MVC 模式。您在此处定义了模型,视图是通过模板(即dashboard.html)实现的,控制器可以是Form您的项目中的。沿着这些思路:
你的dashboard.py:
from django import forms
from .models import Coach, TypeOfTraining, TrainingSchedule
class DashboardForm(forms.Form):
def dashboard(request):
# Extract data from your models here.
return render(
request,
"dashboard.html",
{
"form": form,
"weight_loss_name": some_name,
"weight_loss_amount": some_weight_loss,
})
和你的dashboard.html:
<!-- header and navigation and what not -->
<section class="weightloss">
<h2>Weight Loss</h2>
<div class="person">{{ weight_loss_name }}</div>
<div class="amount">{{ some_weight_loss }}</div>
</section>
<!-- rest of the page -->
- 1 回答
- 0 关注
- 96 浏览
添加回答
举报