Django — create a form with multiple select boxes?
Good day!
I need a page with a form where I can create a location that has a number of characteristics... and, for example, if I choose type of location, then I should be able to choose this location several types
I did something like this:
type_choices = (some choices)
class LocationType(models.Model):
name = models.CharField(max_length=50, verbose_name="Type of location", choices=type_choices)
class Location(models.Model):
types = models.ManyToManyField(LocationType, related_name='location_type')
class LocationForm(forms.ModelForm):
class Meta:
model = Location
but in my form I don't see Cheusov... i.e. the form is blank
1 answer
You need to create choices for location and then create a locations themselves. Or what's the problem?!
Find more questions by tags Django
PS:Judging by the models you have in the admin to select the type of location of proposed options. - Ruben.Price56 commented on July 9th 19 at 14:02
choices get do not need. Look in the admin panel as shown. You just want it to do? - Ruben.Price56 commented on July 9th 19 at 14:11