Answers for "how to link css in django"

CSS
1

css django

{% load static %}

<link rel="stylesheet" type="text/css" href="{% static 'polls/style.css' %}">
Posted by: Guest on October-05-2020
0

link css in django template

<link rel="stylesheet" href="{% static 'css/blog.css' %}">
Posted by: Guest on June-23-2021
0

include css django

#In the setting.py file:
MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media')

MEDIA_URL = '/media/'

STATIC_ROOT = os.path.join(PROJECT_DIR, 'static')

STATIC_URL = '/static/'

STATICFILES_DIRS = (
    os.path.join(PROJECT_DIR, 'staticfiles'),
)

#In your main urls.py file:
from django.conf.urls import patterns, include, url
from django.conf.urls.static import static
from django.contrib import admin
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from myweblab import settings

admin.autodiscover()

urlpatterns = patterns('',
    .......
) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

urlpatterns += staticfiles_urlpatterns()

#Then in your template:
{% load static %}

<link rel="stylesheet" href="{% static 'css/style.css' %}">
Posted by: Guest on November-02-2021

Browse Popular Code Answers by Language