<br /> def subs(request, pk):<br /> sw = Swimmers.objects.filter(id=pk).values('sessions')<br /> sw_list = map(int,sw)<br /> sw_list = map(lambda x: x + 1, sw_list)<br /> return JsonResponse(sw_list, safe=False)</pre><br />
<br /> <pre>class Swimmers(models.Model):<br /> name = models.CharField(max_length=200, blank=False)<br /> lastname = models.CharField(max_length=200, blank=False)<br /> idno = models.CharField(max_length=200, blank=False, null=True)<br /> sessions = models.IntegerField(blank=False)<br /> totalsessions = models.CharField(max_length=200, blank=False )<br /> dateofpayment = models.CharField(max_length=200, blank=False)<br /> session = models.ForeignKey(Session, on_delete=models.SET_NULL, null=True)<br /> <br /> def __str__(self):<br /> return self.name</pre><br />
return JsonResponse(list(sw_list), safe=False)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)