0xDr0id
0xDr0id

Reputation: 319

Django CSS changes are not applied

I am new to Django and I am using a CSS file for my styles and for now the styles are applied to my html. Now I have created a new class:

.post-image {
    height: 500px;
    width: 500px;
  }

and have applied the class to the HTML element I want to style like this:

<img class="post-image" src="{{ post.image.url }}" alt="">

But the class post-image does not apply somehow. When I change it back to the old class the image gets resized. Also when I tried to edit the old class in my main.css the changes were not applied.

My main.css file is in my static directory and I have added the static directory in my settings.py file like this:

STATIC_URL = '/static/'

and I have imported the stylesheet in my base.html like this:

<link rel="stylesheet" type="text/css" href="{% static 'feed/main.css' %}">

Upvotes: 1

Views: 1761

Answers (3)

Ali74
Ali74

Reputation: 1

You must have the following code in the setting.py

STATIC_URL = '/static/'

STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'static'), ]

Upvotes: -1

user10997436
user10997436

Reputation:

To erase the browser cache just press Ctrl + shitf + R

Upvotes: 2

0xDr0id
0xDr0id

Reputation: 319

I had to clear the cache... :)

Upvotes: 4

Related Questions