Hi,
I have a model that contains either a text or a numerical information, based on the type of the entry:
equipment = models.ForeignKey(equipment)
number = models.DecimalField('Amount/number', max_digits=6, decimal_places=2, blank=True, null=False, default=0)
text = models.TextField("Text", blank=True, null=True, default='')
Based on that model I created a model form:
class RoomsetupEquipmentForm(ModelForm):
equipment = forms.ModelChoiceField(queryset=equipment.activeobjects.order_by('category__name', 'name'))
def __init__(self, *args, **kwargs):
super(RoomsetupEquipmentForm, self).__init__(*args, **kwargs)
self.fields['equipment'].choices = equipment_as_choices()
class Meta:
model = roomsetup_equipments
fields = ('equipment', 'number', 'text')
I'm looking for a way to selectively show either the number or the text field when the form is created.
Thomas