14👍
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')
10👍
This was my earlier settings . I am using Python 3.5. Django 2.1.
BASE_DIR = Path(__file__).resolve().parent.parent.parent
STATIC_ROOT = BASE_DIR / 'static'
I changed just one thing:
STATIC_ROOT = str(BASE_DIR / 'static')
It worked fine.
1👍
In my case it was because i installed in manually (which was the old version). the new python versions (>=3.6) have the pathlib library included.
So I simply did pip uninstall pathlib
so that it could use the one that comes already bundled with python. When i ran the code again it worked fine.
- Convert Python None to JavaScript null
- Django: how to change values for nullbooleanfield in a modelform?
0👍
I got the error from some Databricks internal library. I had imported Pathlib because I needed to get the current working directory.
When I removed
from pathlib import Path
and used
os.getcwd()
to get the current directory it started working. Looks like Pathlib changed sys.path to return a list of PosixPath objects instead of a list of strings.
- Best way to reference the User model in Django >= 1.5
- Paypal monthly subscription plan settings for first day of the month and making monthly recurring payment – django python
- Registered models do not show up in admin
- Accessing Django OneToOneField in templates?