how to configure django form to create select option with query specific. Example1, i need create a select with user below a group but if i use just model i have every user, and just need the users specific.
Example2. i have this models:
class Fruit(models.Model):
name = models.CharField(max_length=150)
color = models.CharField(max_length=150)
I Have this datas
[apple, red], [banana, yellow], [strammberry, red], [orange, orange]...
when i create my form i need select field that show me fruits color red. apple, strammberry.
but show me all fruit. apple, banana, strammberry, orange
what is the form to this do?
You can use a ChoiceField in your form, or if you want the choices to be determined by a query, then a ModelChoiceField.