I have a model
class Location(models.Model):
country = models.ForeignKey('LocationCountry',null = True,blank = True)
city = models.ForeignKey('LocationCity',null = True,blank = True)
locality = models.ForeignKey('LocationLocality',null = True,blank = True)
The form for this model is as follows
class LocationForm(ModelForm):
class Meta:
model = Location
Th country,city and locality being FK come as drop down lists.
What i want to do is make them like radio select i.e. if i select an item from country then the city and locality item selected should become null. So at any instance only 1 of them is selected.
Is the question clear ? Any help will be highly appreciated.
I think (as tony mentioned in his comment) that you would get there with Javascript. There are plenty of examples of dropboxes influencing other dropboxes (like this thorough explanation). I suggest you take a look at that example, and see if you can mold it to the behavior you want. If it doesn’t work out for you, you should perhaps rephrase your question the exact problem you are having with the synchronization between the dropdowns.