Hi
My app have these three models
users
class Customers(models.Model):
customer_id = models.PositiveIntegerField(unique=True, verbose_name='کد مشتری')
f_name = models.CharField(verbose_name='نام')
l_name = models.CharField(verbose_name='نام خانوادگی')
national_id = models.CharField(
validators=[RegexValidator('[0-9]{10}', message='کدملی معتبر نیست')], max_length=10, verbose_name='کدملی')
state_code = models.ForeignKey(StateCodes, on_delete=models.CASCADE, verbose_name='استان')
city = models.CharField(verbose_name='شهر')
address = models.CharField(verbose_name='آدرس')
postal_code = models.CharField(
validators=[RegexValidator('[0-9]{10}', message='کدپستی معتبر نیست')], max_length=10, verbose_name='کدپستی')
email = models.EmailField(unique=True, verbose_name='آدرس ایمیل')
cellphone_number = models.CharField(
validators=[RegexValidator('[0][9][0-9]{9}', message='شماره تلفن معتبر نیست')],
max_length=11, verbose_name='تلفن همراه')
comments
class Comments(models.Model):
goods = models.ForeignKey(Goods, on_delete=models.CASCADE, verbose_name='کد کالا', related_name='comments')
customer = models.ForeignKey(CustomUser, on_delete=models.CASCADE, verbose_name='کد مشتری')
text = models.TextField(verbose_name='متن نظر', help_text='متن نظر را وارد کنید')
date = models.DateTimeField(auto_now=True, verbose_name='تاریخ ثبت رای')
and vote
class Vote(models.Model):
comment = models.ForeignKey(Comments, on_delete=models.CASCADE, null=True, blank=True,
related_name='comment_vote', verbose_name='نظر مربوطه')
customer = models.ForeignKey(CustomUser, on_delete=models.CASCADE, null=True, blank=True,
related_name='comment_user', verbose_name='کاربر نظر داده')
type = models.BooleanField(verbose_name='نوع نظر')
voted_customer = models.ManyToManyField(CustomUser, verbose_name='کاربران رای داده',
related_name='comment_likes')
i managed to capture customer votes(like or dislike ) for a certain comment of a product
the thing that i want to do now is to calculate number of likes and dislike of any comment about any product how could i do that?
i defined several queries to gain that but no success
any help would be appreciated.