[Answered ]-How to Loading Static Files in Django Template?

1👍

Solution:

  1. Updating STATICFILES_DIRS: In the settings.py file, the user had initially configured STATICFILES_DIRS with the path 'C:/user/templates/user/static'. However, this path structure was incorrect.

  2. Removing Leading Slash: The user removed the leading slash before 'user/templates/user/static' in the os.path.join call to establish a proper path.

    STATICFILES_DIRS = [os.path.join(BASE_DIR, 'user/templates/user/static')]
    
  3. Using Forward Slashes: The user ensured the use of forward slashes / in the directory path, even on Windows systems, as Python and Django internally handle path conversions.

  4. Restarting Server: After applying these changes, the user restarted the Django development server to enact the configuration.


Leave a comment