Skip to content Skip to sidebar Skip to footer

Return Database_name == ':memory:' Or 'mode=memory' In Database_name Typeerror: Argument Of Type 'windowspath' Is Not Iterable

I am practicing Django but when I command python manage.py makemigration and python manage.py migrate then I got an error as show in the title. the full error is mentioned below: C

Solution 1:

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.

Solution 2:

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

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

Solution 3:

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.

Post a Comment for "Return Database_name == ':memory:' Or 'mode=memory' In Database_name Typeerror: Argument Of Type 'windowspath' Is Not Iterable"