Skip to content

Instantly share code, notes, and snippets.

@prashantsengar
Last active January 30, 2021 07:37
Show Gist options
  • Save prashantsengar/74822a3d3a9030b5206e00d3d59f0375 to your computer and use it in GitHub Desktop.
Save prashantsengar/74822a3d3a9030b5206e00d3d59f0375 to your computer and use it in GitHub Desktop.
Django Fixing Errors and Tips

Django Fixing Errors and Tips

To help me and others who are working with Django. These are the snippets of code that I used to fix some of the problems that I encountered, or to add something new.

TypeError: argument of type 'WindowsPath' is not iterable

Full traceback

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 "P:\Projects\AIH 2020\newadmin\Django-custom-registration\ENV\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "P:\Projects\AIH 2020\newadmin\Django-custom-registration\ENV\lib\site-packages\django\core\management\__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "P:\Projects\AIH 2020\newadmin\Django-custom-registration\ENV\lib\site-packages\django\core\management\base.py", line 341, in run_from_argv
    connections.close_all()
  File "P:\Projects\AIH 2020\newadmin\Django-custom-registration\ENV\lib\site-packages\django\db\utils.py", line 230, in close_all
    connection.close()
  File "P:\Projects\AIH 2020\newadmin\Django-custom-registration\ENV\lib\site-packages\django\utils\asyncio.py", line 26, in inner
    return func(*args, **kwargs)
  File "P:\Projects\AIH 2020\newadmin\Django-custom-registration\ENV\lib\site-packages\django\db\backends\sqlite3\base.py", line 261, in close
    if not self.is_in_memory_db():
  File "P:\Projects\AIH 2020\newadmin\Django-custom-registration\ENV\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 "P:\Projects\AIH 2020\newadmin\Django-custom-registration\ENV\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

This can be fixed by going to your settings.py file and doing this:

Changing this to

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR \ 'db.sqlite3',
    }
}

This

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

Implementing Multiple User Types in Django

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment