[Fixed]-Return database_name == ':memory:' or 'mode=memory' in database_name TypeError: argument of type 'WindowsPath' is not iterable

30πŸ‘

βœ…

It seems like the setting DATABASES – NAME expects a string, not a Path object.

In your settings try changing this line

'NAME': BASE_DIR / 'db.sqlite3',

to

'NAME': str(BASE_DIR / 'db.sqlite3'),

so that NAME is a string instead of a Path.


The error comes from this line of code django/db/backends/sqlite3/creation.py#L13 and it seems that this commit solves the issue, so in Django v3.1.1 there is no need to use 'NAME': str(BASE_DIR / 'db.sqlite3'), anymore, just using 'NAME': BASE_DIR / 'db.sqlite3', should sufice.

πŸ‘€Ralf

3πŸ‘

I fixed this error by changing the line for database name in file settings.py to:

'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),

0πŸ‘

I had a similar issue which I resolved by changing the owner of the files to the current owner and starting the server using the following command sudo -u <user_name> python3 manage.py runserver. It seems it’s a permission issue.

πŸ‘€farch

0πŸ‘

I had the same issue and resolved it by creating a virtual environment for the project. Run the following command to install the environment: python -m venv learn more from https://docs.python.org/3/tutorial/venv.htmlnv.html

πŸ‘€Alphamale

Leave a comment