Running collectstatic on server : AttributeError: 'PosixPath' object has no attribute 'startswith' Running collectstatic on server : AttributeError: 'PosixPath' object has no attribute 'startswith' django django

Running collectstatic on server : AttributeError: 'PosixPath' object has no attribute 'startswith'


You're using Python 3.5. Support for Path objects in the os module was added in Python 3.6. You can:

  • either upgrade to Python 3.6; or

  • avoid using Path objects:

    BASE_DIR = os.path.abspath(os.path.join(__file__, '../../../'))MEDIA_ROOT = os.path.join(BASE_DIR, 'media')STATIC_ROOT = os.path.join(BASE_DIR, 'static')


This was my earlier settings . I am using Python 3.5. Django 2.1.

BASE_DIR = Path(__file__).resolve().parent.parent.parentSTATIC_ROOT = BASE_DIR / 'static'

I changed just one thing:

STATIC_ROOT = str(BASE_DIR / 'static')

It worked fine.