django iterating through a list from models in html need help
class Input(models.Model):
roomlist = models.TextField(max_length=50, default=0)

I have openpyxl which outputs a list, and i send it to roomlist from when user clicks submit button to store the output list in roomlist variable.
roomlist looks like something like this:
[‘0.210 W/sq ft’, ‘System Description: Split System’, ‘G1 - P100L Elev Lobby’, ‘267 ft²’, ‘10.0 ft’, ‘None’, ‘1.0 ft’, ‘0 People’, ‘None’, ‘0.210 W/sq ft’, ‘System Description: Split System’, ‘G1 - P101 Maintenance RM’, ‘309 ft²’, ‘10.0 ft’, ‘None’, ‘1.0 ft’, ‘0 People’, ‘None’]
When i try to iterate through the list in html using
{% for x in input.roomlist %}

{% endfor %}

instead of it iterating through each item in the list, it iterates through each character in each string stored in the list. How can i make it iterate through the list item instead of character in each item?

You need to split the field into the individual elements in the view, then pass that list to the template in the context.

(Depending upon the larger context of the application, what I would do is consider storing the data appropriately within the model and not just as a string.)

Thank you for the response,

I am very new to django, and I am a bit confused about how i would split the field into individual element in the view before passing it to template. Basically the list has x number of room’s information and every n’th element in the list signals a different room. i am trying to create at able in html that shows each room’s information when user clicks a submit button and the backend goes through the excel file.
Also, how can i store this properly in a model instead of storing it just as a list? I tried creating a one to many relationship model but it wasn’t clear to me how the data would be properly stored.

For us to be able to provide more tangible assistance, you’re going to need to provide a lot more detail about the models, views, and forms involved, along with providing a sample of the data.

Also, have you worked your way through the Official Django Tutorial? If not, you should. It covers a lot of the fundamentals, including using Foreign Keys to track relationships between models.

i think the problem i have is that i declared the field to be charfield, so when i pass the list to html it thinks the whole list as a one big string. I am trying to change the field into ArrayField to see if it works.