Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: argument of type 'WindowsPath' is not iterable - in django python [duplicate]

Tags:

python

django

whenever I run the server or executing any commands in the terminal this error is showing in the terminal. The server is running and the webpage is working fine but when I quit the server or run any commands(like python manage.py migrate) this error is showing.

   `Watching for file changes with StatReloader
    Performing system checks...
    
    System check identified no issues (0 silenced).
    September 21, 2020 - 12:42:24
    Django version 3.0, using settings 'djangoblog.settings'
    Starting development server at http://127.0.0.1:8000/
    Quit the server with CTRL-BREAK.

Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    main()
  File "manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "C:\Python37\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "C:\Python37\lib\site-packages\django\core\management\__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Python37\lib\site-packages\django\core\management\base.py", line 341, in run_from_argv
    connections.close_all()
  File "C:\Python37\lib\site-packages\django\db\utils.py", line 230, in close_all
    connection.close()
  File "C:\Python37\lib\site-packages\django\utils\asyncio.py", line 24, in inner
    return func(*args, **kwargs)
  File "C:\Python37\lib\site-packages\django\db\backends\sqlite3\base.py", line 261, in close
    if not self.is_in_memory_db():
  File "C:\Python37\lib\site-packages\django\db\backends\sqlite3\base.py", line 380, in is_in_memory_db
    return self.creation.is_in_memory_db(self.settings_dict['NAME'])
  File "C:\Python37\lib\site-packages\django\db\backends\sqlite3\creation.py", line 12, in is_in_memory_db
    return database_name == ':memory:' or 'mode=memory' in database_name
TypeError: argument of type 'WindowsPath' is not iterable
`
like image 594
Faiz P Avatar asked Sep 21 '20 07:09

Faiz P


1 Answers

I got this cleared by changing DATABASES in settings.py file:

change

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

to

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

this works

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': str(os.path.join(BASE_DIR, "db.sqlite3"))
    }
}
like image 71
Faiz P Avatar answered Oct 06 '22 00:10

Faiz P