Check vote score. Vote score can only be 0 or positive

This commit is contained in:
sosokker 2023-09-07 22:34:36 +07:00
parent 215be4d95c
commit 32605720fc

View File

@ -14,6 +14,7 @@ import datetime
from django.db import models from django.db import models
from django.utils import timezone from django.utils import timezone
from django.contrib import admin from django.contrib import admin
from django.core.validators import MaxValueValidator, MinValueValidator
class Question(models.Model): class Question(models.Model):
@ -90,7 +91,7 @@ class Choice(models.Model):
question = models.ForeignKey(Question, on_delete=models.CASCADE) question = models.ForeignKey(Question, on_delete=models.CASCADE)
choice_text = models.CharField(max_length=200) choice_text = models.CharField(max_length=200)
votes = models.IntegerField(default=0) votes = models.PositiveIntegerField(default=0, validators=[MinValueValidator(0), MaxValueValidator(2147483647)])
def __str__(self): def __str__(self):
""" """