Home > Net >  AttributeError: 'WindowsPath' object has no attribute 'rpartition' when setting
AttributeError: 'WindowsPath' object has no attribute 'rpartition' when setting

Time:10-30

After typing

STATIC_ROOT = BASE_DIR / "staticfiles"

in settings.py I get the error in the tittle.

I tried with STATICDIR but it still doesn't work. I am pretty new to django so I don't really know other ways to fix it.

EDIT: turns out I tried to install the template folder in the INSTALLED APPs thingy

CodePudding user response:

Simply you can try following way:

STATIC_URL = '/static/'

STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]

And in your template, load the static using following tag:

{% load static %}

CodePudding user response:

STATIC_ROOT (and all other path-related options) must be a string, not a Path.

Cast it in the assignment:

STATIC_ROOT = str(BASE_DIR / "staticfiles")
  • Related