刚开始我的 Python/Django 体验,我有一个问题 :-)
所以我有一个这样的model.py:
from django.db import models
class Priority(models.Model):
name = models.CharField(max_length=100)
class Projects(models.Model):
name = models.CharField(max_length=30)
description = models.CharField(max_length=150)
priority = models.ForeignKey(Priority)
class Tasks(models.Model):
name = models.CharField(max_length=30)
description = models.CharField(max_length=40)
priority = models.ForeignKey(Priority)
在优先级表中,我计划存储 1.High、2.Medium、3.Low 等数据,在 Tasks 表中,优先级将存储为 id(1、2 或 3)
问题是如何编写一个视图来显示我的所有任务但命名为优先级?例如:
name: Task 1
description: Description 1
priority: **High**