Right now I'm trying to use some basic CSS in my Django Hello World program. I can get "Hello World" to display, but the CSS effect isn't work. Currently this is what I have in my main URL:
from django.conf.urls import url, include
from django.contrib import admin
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'',include('firstapp.urls')),
]
And this is what I have in my app URL.
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^$', views.index, name='index'),
]
This is my views file.
from django.shortcuts import render
from django.http import HttpResponse
def index(request):
context = {"variable":"Hello World"}
return render(request, "base.html", context)
My base.html file
{% load staticfiles %}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Title of the document</title>
<link rel='stylesheet' href='{% static "css/base.css" %}'/>
</head>
<html>
<p>{{ variable }}</p>
<script src="{% static "base.js'" %}"></script>
</body>
</html>
And my base.css file.
h1 {
color: 00FFFF;
}
Lastly, I added this piece of code on the bottom of my settings file.
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
]
STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static_cdn")
Ideally the page should show up with "Hello World" in a cyan color...unfortunately it just shows "Hello World" in normal black text. Does anyone know why this is?