我有一个工作经验模型(work_experience),包含一个“is_working”字段,当用户仍在公司工作时为true。
在前端,我使用了一个切换开关(toggle switch),我想在点击时更改布尔字段值“is_working”。那应该使用怎样的逻辑在Django中实现切换开关?
切换开关
HTML:
<div style="display:inline-block">
<label>Currently working here?</label>
<label class="switch">
<input type="checkbox">
<span class="slider round"></span>
</label>
</div>
模型
class Work_Experience(models.Model):
job_title = models.CharField(max_length=100, null=True, blank=True)
company = models.CharField(max_length=100, null=True, blank=True)
description = models.CharField(max_length=300, null=True, blank=True)
exp_start_date = models.DateField(null=True, blank=True)
exp_end_date = models.DateField(null=True, blank=True)
is_working = models.BooleanField(default=False)