D
D
Dennis2016-05-16 15:23:24
Django
Dennis, 2016-05-16 15:23:24

Django - Creating a form with multiple select field?

Good afternoon!
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 a location type, then I should be able to select several types for this location,
I did this:
type_choices = (some choices)
class LocationType (models.Model):
name = models.CharField(max_length=50, verbose_name="Location type", choices=type_choices)
class Location(models.Model):
types = models.ManyToManyField(LocationType, related_name='location_type')
class LocationForm(forms.ModelForm):
class Meta:
model = Location
but I don't see any Choices in my form...i.e. the form is empty

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladislav Sklyar, 2016-05-17
@VladSkliar

You need to create choices for the location, and then create the locations themselves. Or what's the problem?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question