I have made a feedback form. Now I want to make a user list of those who have given feedback on the particular product. My motive is, that if any user gives feedback on a particular product, he/she won't be able to give another feedback on that particular product and can't see the feedback form. A user can share just one feedback on one product. But he/she will be able to give feedback on other's products. How can I make a user list of those who have given feedback on the particular product? Help me...
models.py:
class Products(models.Model):
user = models.ForeignKey(User, related_name="merchandise_product_related_name", on_delete=models.CASCADE, blank=True, null=True)
product_title = models.CharField(blank=True, null=True, max_length = 250)
on_delete=models.CASCADE, blank=True, null=True)
def __str__(self):
return str(self.pk) + "." + str(self.product_title)
class ProductREVIEWS(models.Model):
user = models.ForeignKey(User, related_name='userREVIEW',on_delete=models.CASCADE)
product = models.ForeignKey(Products, related_name='productREVIEWrelatedNAME',on_delete=models.CASCADE)
def __str__(self):
return str(self.pk) + "." + str(self.product) + "(" + str(self.user) + ")"
views.py:
def quick_view(request, quick_view_id):
quick_view = get_object_or_404(Products, pk=quick_view_id)
AllProductFeedback = quick_view.productREVIEWrelatedNAME.all()
TotalProductsFeedback = AllProductFeedback.count()
OverallFeedback = ProductREVIEWS.objects.all()
context = {
"quick_view":quick_view,
"TotalProductsFeedback":TotalProductsFeedback,
"AllProductFeedback":AllProductFeedback,
"OverallFeedback":OverallFeedback,
}
return render(request, 'quickVIEW_item.html', context)