[Django] How do I filter the choices in a ModelForm that has a CharField with the choices attribute
- by nubela
I understand I am able to filter queryset of Foreignkey or Many2ManyFields, however, how do I do that for a simple CharField that is a Select Widget (Select Tag).
For example:
PRODUCT_STATUS = (
("unapproved", "Unapproved"),
("approved", "Listed"),
#("Backorder","Backorder"),
#("oos","Out of Stock"),
#("preorder","Preorder"),
("userdisabled", "User Disabled"),
("disapproved", "Disapproved by admin"),
)
and the Field:
o_status = models.CharField(max_length=100, choices=PRODUCT_STATUS, verbose_name="Product Status", default="approved")
Suppose I wish to limit it to just "approved" and "userdisabled" instead showing the full array (which is what I want to show in the admin), how do I do it?
Thanks!