I have a MultipleChoiceField forms field which shows up in the database like 
this <https://i.stack.imgur.com/ZvBB2.png>. It seems to have been converted 
to a string in the database, because when I try to display it with a 'for 
property in property_type' statement in the HTML, it shows up like this 
<https://i.stack.imgur.com/gnSFc.png>. I want it to be displayed like this 
<https://i.stack.imgur.com/f3tHU.png>.  I have also tried using an 
ArrayField (shown below), but the result is the same.


models.py:

property_type = models.CharField(max_length=50, help_text="You can select more 
than 1 option")

property_type = ArrayField(models.CharField(max_length=50), help_text="You can 
select more than 1 option"))


forms.py:

property_type = forms.MultipleChoiceField(widget=forms.SelectMultiple, 
choices=BuyerListing.PROPERTY_TYPE)

HTML:

    {% for property in listing.property_type %}
    <p>Property type: {{ property }}</p>
    {% endfor %}



How do I get this MultipleChoiceField to load as a list so I can display it 
properly with a for statement?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/cb625aff-b96e-4a07-9737-d89805085962%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to