'Django Admin filter then exclude not working in my project

When i am filtering, i am getting all the products name , that i am not expecting also those products are not assigned to any country just list of name products.

i made this query to exclude but not working.

admin.py

    def formfield_for_manytomany(self, db_field, request, product_name=None, product_name__isnull= True, **kwargs):
    if db_field.name == "product_name" :
        kwargs["queryset"] = models.ProductName.objects.filter(product_name == request._user_country).exclude(product_name__exists == None)
    return super().formfield_for_foreignkey(db_field, request, **kwargs)

model.py

class Product(models.Model):
name = models.ManyToManyField(
    ProductName, verbose_name=_("Products Name")
country = models.ForeignKey(Country, on_delete=models.CASCADE, verbose_name=_("Country"))


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source