From 90cb914035d766eba1ee0a23859821c71b7935e8 Mon Sep 17 00:00:00 2001 From: shreys7 Date: Mon, 2 Dec 2019 08:11:04 +0530 Subject: [PATCH] Added support for including our own css files --- todoApp/staticfiles/css/style.css | 4 ++++ todoApp/todoApp/settings.py | 8 ++++++++ todoApp/todoApp/urls.py | 6 +++++- todoApp/todos/templates/todos/base.html | 4 ++++ 4 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 todoApp/staticfiles/css/style.css diff --git a/todoApp/staticfiles/css/style.css b/todoApp/staticfiles/css/style.css new file mode 100644 index 00000000..2d2e8a68 --- /dev/null +++ b/todoApp/staticfiles/css/style.css @@ -0,0 +1,4 @@ +.page-header { + width: 50%; + margin: 0 auto; +} \ No newline at end of file diff --git a/todoApp/todoApp/settings.py b/todoApp/todoApp/settings.py index 0a2423e7..c75692b6 100644 --- a/todoApp/todoApp/settings.py +++ b/todoApp/todoApp/settings.py @@ -118,4 +118,12 @@ # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/2.2/howto/static-files/ +MEDIA_ROOT = os.path.join(BASE_DIR, 'media') +MEDIA_URL = '/media/' + +STATIC_ROOT = os.path.join(BASE_DIR, 'static') STATIC_URL = '/static/' + +STATICFILES_DIRS = ( + os.path.join(BASE_DIR, 'staticfiles'), +) diff --git a/todoApp/todoApp/urls.py b/todoApp/todoApp/urls.py index 3708ffe7..2cf747e3 100644 --- a/todoApp/todoApp/urls.py +++ b/todoApp/todoApp/urls.py @@ -15,8 +15,12 @@ """ from django.contrib import admin from django.urls import path, include +from django.conf.urls.static import static +from django.contrib.staticfiles.urls import staticfiles_urlpatterns +from . import settings urlpatterns = [ path('todos/', include('todos.urls')), path('admin/', admin.site.urls), -] +] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) +urlpatterns += staticfiles_urlpatterns() diff --git a/todoApp/todos/templates/todos/base.html b/todoApp/todos/templates/todos/base.html index d2993962..0c32cdb1 100644 --- a/todoApp/todos/templates/todos/base.html +++ b/todoApp/todos/templates/todos/base.html @@ -1,3 +1,4 @@ +{% load static %} @@ -7,6 +8,9 @@ + + + {% block title %} {% endblock %}