I have a model of categories with a title
class Category(models.Model):
user = models.ForeignKey(user, on_delete=CASCADE)
title = models.CharField(max_length = 20)
I have another model with many to many field of categories
class Product(models.Model):
user = models.ForeignKey(user, on_delete=CASCADE)
Category = models.ManyToManyField(Category)
title = models.CharField(max_length = 20)
Both my models got a user foreign key.
I created a product form using django modelforms.
class ProductForm(forms.ModelForm):
class Meta:
model = Product
fields = '__all__'
The issue I face is that I get the category of another user also. how to show only categories of that particular user? so that one user won't see another user's category