Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Django CSS
#1
Hi all.
I downloaded a free website template from travello website. In html file I am configuring CSS , I used {% load static %} at beginning of index.html file
at style {% static ''%} at script {% static''%} i used those lines. The issue is I am not getting CSS styles and images on my Django website .What should I do to get images and styles to my website in index.html. Please see my attachment to understand my problem.
Thanks for your support in advance!

Attached Files

Thumbnail(s)
   
Reply
#2
add this tag at the top of your html file:

Output:
{% load static %}
add django.contrib.staticfiles in the installed apps of your settings.py file

INSTALLED_APPS = [
    ...
    'django.contrib.staticfiles',
    ...
]
and check this setting or add these lines into your settings.py file

Output:
STATIC_URL = '/static/' STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')] STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
you can check my blog post about static files here: https://web-spidy.com/manage-django-static-files-images-javascript-css/

Or you can dm me.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Django: How to automatically substitute a variable in the admin page at Django 1.11? m0ntecr1st0 3 3,452 Jun-30-2019, 12:21 AM
Last Post: scidam

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020