Home>

How to make it so that only the creator of the model can see it, but other participants cannot see it?

i have a models.py model

class Product (models.Model):
    username= models.CharField (max_length= 100)
    first_name= models.CharField (max_length= 100)
    last_name= models.CharField (max_length= 100)
    email= models.EmailField (max_length= 254)
    image= models.ImageField (upload_to= 'media /', blank= True, null= True)
    company_name= models.CharField (max_length= 100)
    def __str __ (self):
        return self.username

views.py

class ProductListView (ListView):
    model= Product
    queryset= Product.objects.all ()
    template_name= 'products_list.html'
class ProductDetailView (DetailView):
    model= Product
class NewProductView (LoginRequiredMixin, CreateView):
    template_name= 'product_form.html'
    model= Product
    form_class= NewProductForm
    success_url= reverse_lazy ('product_list_page')
class EditProductView (LoginRequiredMixin, UpdateView):
    template_name= 'product_form.html'
    model= Product
    form_class= EditProductForm
    success_url= reverse_lazy ('product_list_page')

How do I limit the visibility of a model to its creator only?