Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Django loading static files
#8
(Oct-13-2017, 09:57 AM)Dutchpy Wrote: is that the error message you referred to?


Sorry my bad, Django doesn't give an error for static files its only templates.

You are getting 404 not found error.
refer to: https://docs.djangoproject.com/en/2.0/ho...tic-files/

make sure you have these settings:

PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
BASE_DIR = os.path.dirname(PROJECT_DIR)

# Static files (CSS, JavaScript, Images)
STATICFILES_FINDERS = [
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
]

STATICFILES_DIRS = [                # For static files not particular to any app.
    os.path.join(PROJECT_DIR, 'static'),
]

STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = '/static/'                # eg 127.0.0.1/static/
If still, it doesn't work try:
python manage.py collectstatic

And check your STATIC_ROOT. Your file should exist there and be served too.
Reply


Messages In This Thread
Django loading static files - by Dutchpy - Oct-11-2017, 03:03 PM
RE: Django loading static files - by nilamo - Oct-11-2017, 09:51 PM
RE: Django loading static files - by Dutchpy - Oct-12-2017, 07:49 PM
RE: Django loading static files - by buran - Oct-12-2017, 09:05 PM
RE: Django loading static files - by Dutchpy - Oct-12-2017, 09:40 PM
RE: Django loading static files - by hbknjr - Oct-13-2017, 07:54 AM
RE: Django loading static files - by Dutchpy - Oct-13-2017, 09:57 AM
RE: Django loading static files - by hbknjr - Oct-13-2017, 10:25 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question [Solved] Private static files SpongeB0B 1 1,069 Jul-16-2022, 05:36 AM
Last Post: SpongeB0B
  Flask, Display a picture outisde the static SpongeB0B 6 15,554 Aug-29-2020, 05:15 PM
Last Post: nilamo
  SHow image in a static link of Django pycada 3 2,571 Mar-04-2020, 01:50 AM
Last Post: pycada
  Django problem with files menator01 1 1,967 Jan-05-2020, 04:20 PM
Last Post: menator01
  Django: How to automatically substitute a variable in the admin page at Django 1.11? m0ntecr1st0 3 3,334 Jun-30-2019, 12:21 AM
Last Post: scidam
  django herf not loading right LK1097 0 2,088 May-31-2018, 06:59 AM
Last Post: LK1097
  first django site-ms word/pdf files jon0852 1 4,396 Nov-19-2017, 08:39 PM
Last Post: homayoon_hashemi

Forum Jump:

User Panel Messages

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