Skip to content
Advertisement

Array to string with Django and MySQL

I need to design SQL query in html on Django

I have an array in my table like :

list = ['aa', 'bb', 'cc']

When I call this array in my page :

<p>{{ list }}</p>

I have : [‘aa’, ‘bb’, ‘cc’]

What do I do if I want :

a

b

c

I tried with .split(‘,’) but I’ve already ‘[]’

I tried with for item in list but I’ve :

[

a

a

,

b

b

,

c

c

,

]

Could you help me please ?

Advertisement

Answer

I tried to load it as a json but it doesn’t work.

I’ve solved my problem with

import ast
lst = ast.literal_eval(st)
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement