MMMMMCCLXXVII
MMMMMCCLXXVII

Reputation: 581

How can i use my css in html

The items are inside my django project

I have the templates directory like this :

|base.html
|
|rules
   | 
   |style_base.css

and i set the link label in my base.html which could be:

<link type="text/css" href="/rules/style_base.css" rel="stylesheet" />

but i can't get the css when i use firebug to check if it works.

What firebug shows to me is 'There are no rules. You can create a rule.'

and i see a optional selection says 127.0.0.1:8000/rules/stye_base.css

I don't want to cite it via urls but my local directory.

So how should i cite style_base.css?

Upvotes: 0

Views: 62

Answers (2)

mortymacs
mortymacs

Reputation: 3726

Edit your settings.py file and change these variables values:

STATIC_URL = '/rules/'
STATICFILES_DIR = ( os.path.join(BASE_DIR,'templates/rules'), )

And use it in templates:

<link type="text/css" href="{{STATIC_URL}}style_base.css" rel="stylesheet" />

Upvotes: 1

Andy G
Andy G

Reputation: 19367

Remove the first forward-slash, it will look from the current location.

With the forward-slash it looks from the root-directory, which is not necessarily the same as the current location.

Upvotes: 2

Related Questions