Find more articles in our new Python Knowledge Base

Not using forward slashes

Django requires you to use forward slashes / whenever you indicate a path, even on Windows. In your settings, this is true for the following variables.

  • STATICFILES_DIRS
  • TEMPLATE_DIRS
  • DATABASES['<your database>'][NAME]
  • FIXTURE_DIRS

Anti-pattern

This pattern is exemplary for any of the above mentioned settings. It uses backslashes, instead of forward slashes.

""" settings.py """

STATICFILES_DIRS = [
    "\\path\\to\\my\\static\\files",
]

Best practice

Django requires you to use forward slashes /, even on Windows.

""" settings.py """

STATICFILES_DIRS = [
    "/path/to/my/static/files",
]