[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

Leave a comment