I want to pass Hex Colour Code into a CSS inline style on an HTML page

I have a Django project that has a database of colours with their Hex values. I want to display this as a swatch in a table.

 <tbody>
            {% for item in items_page %}
    
                    <tr>               
                        <td scope="row">{{ item.manufacturer }}</td>
                        <td scope="row">{{ item.paintname }}</td>
                        <td scope="row">{{ item.hexcode }}</td>
                        <td scope="row">{{ item.type }}</td>
                        <td scope="row">{{ item.colourcategory }}</td>
                        <td scope="row" style='background-color :{{item.hexcode}}'></td>
                        
                    </tr>

The issue I have is that this works and displays the swatches but the last line has errors flagged on it. The error red lines are under the <td tag, the word color and the {{item.hexcode}} code. It works but I worry that because of the error it may break further down the line. Is there a correct way of achieving what I am trying to do? Thanks

Вернуться на верх