I want to make (ordered) Song list form.
models.py
class Song(models.Model):
title = models.CharField(max_length=60)
class List(models.Model):
title = models.CharField(max_length=100)
songs = models.ManyToManyField(Song, through='Order')
class Order(models.Model):
list = models.ForeignKey(List)
song = models.ForeignKey(Song)
order = models.IntegerField(unique=True)
and,
forms.py
class ListEditForm(forms.Form):
title = forms.CharField(
label='List Title',
widget=forms.TextInput(attrs={'size':100})
)
songs = forms.ModelMultipleChoiceField(
label= 'Song Order',
required= False,
widget=forms.CheckboxSelectMultiple,
queryset= Song.objects.none()
)
and then,
ListEditForm.py
<form id="edit-form" method="post" action="/list/edit/">
<p>
{{ form.title.errors }}
{{ form.title.label_tag }}
{{ form.title }}
</p>
<p>
{% for song in form.songs %}
{{ song.label_tag }}
{{ song }}
{% endfor %}
</p>
<input type="submit" value="save" />
</form>
This template raises following error: Caught an exception while rendering: 'BoundField' object is not iterable
How do I split render each form field in 'form.songs'?