I have a model
class Demande_Expertise(models.Model):
user = models.ForeignKey(User)
material = models.CharField(_('material'), max_length=30)
categorie = models.ForeignKey("Category")
class Category(models.Model):
name = models.CharField(_('name'), max_length=50)
I have for the class Category the records : Alloys, Ceramic, Composite, Cu_based, Metals, Pure_metals, Ni_based
form
class Demande_ExpertiseForm(forms.ModelForm):
class Meta:
model = Demande_Expertise
exclude = ('etat',)
def __init__(self, *args, **kwargs):
super(Demande_ExpertiseForm, self).__init__(*args, **kwargs)
template
<td>{{ form.categorie}}</td>
How do I get the form if I want to have for the template : Ceramic, Cu_based, Ni_based ?
if I write in Demande_ExpertiseForm
self.fields['categorie'].queryset = Category.objects.filter(name__icontains="Cu_based")
I get only the filter for Cu_based
if I want the filter for Ceramic, Cu_based, Ni_based how to do ?