After following various tutorials, including one on LinkedIn, I believe my Django settings are correct. However, I am facing an issue with the CSS stylesheet in my app. The styling works perfectly everywhere except for the section where I retrieve data from PostgreSQL. Strangely, when I remove the PostgreSQL code, the CSS starts working again in that area. I have also made sure to include {% load static %} at the top of my HTML file.
Below is the HTML snippet:
Code Snippet when it works:
<div class="skills">
<h2>Stories!!!!</h2>
<div class="skill-row">
<img class="princess-img" src="https://media.giphy.com/media/ZETg64fW7xb0gr4NEz/giphy.gif" alt="princess-img">
<h3><a href="Repunzel.html">Repunzel!!</a></h3>
<p>Lets see how Repunzel manages to escape the tower, have an adventure and finds out the truth!!.</p>
</div>
<div class="skill-row">
<img class="alladin-img" src="https://media.giphy.com/media/OoOvAC7vASedB6EhpS/giphy.gif" alt="alladin-img">
<h3><a href="Allading.html">Alladin!!</a></h3>
<p>Let's see if Kitty, Jasmine and Alladin manage with Genies' help to outsmart the baddies!!.</p>
</div>
</div>
/When it doesn't work/
<div class="skills">
<h2>Stories!!!!</h2>
{% for drawing in drawings.all %}
<div class="skill-row">
<img class="{{drawing.classname}}" src="{{drawing.source}}" alt="{{drawing.classname}}">
<h3><a href="{% url 'detail' drawing.id %}">Repunzel!!</a></h3>
<p>{{ drawing.summary }}</p>
</div>
{% endfor %}
</div>
The issue seems to be related to the CSS styling not working within the Django for loop when retrieving data from PostgreSQL using the drawing object defined in my model. Although I do connect to the database and retrieve the data, the specific part styled by CSS is affected.
Below are the views and models code:
#views.py
from django.shortcuts import render,get_object_or_404
from .models import Drawing
def drawingshome(request):
drawings = Drawing.objects
return render(request, 'drawings/drawingshome.html',{'drawings':drawings})
#models.py
from django.db import models
class Drawing(models.Model):
image = models.ImageField(upload_to='images/')
summary = models.CharField(max_length=200)
classname = models.CharField(max_length=200, default='0000000')
source = models.CharField(max_length=200, default='0000000')
altname = models.CharField(max_length=200, default='0000000')
def __str__(self):
return self.summary
Thank you for taking the time to assist me with this issue!