Forums

This error keeps showing up , someone please help!

Error running WSGI application

2021-08-07 14:20:53,803: TypeError: unsupported operand type(s) for /: 'str' and 'str'

2021-08-07 14:20:53,803: File "/var/www/mankavilla_pythonanywhere_com_wsgi.py", line 10, in <module>

2021-08-07 14:20:53,803: application = StaticFilesHandler(get_wsgi_application())

File "/home/mankavilla/.virtualenvs/django3/lib/python3.6/site-packages/django/core/wsgi.py", line 12, in

get_wsgi_application

2021-08-07 14:20:53,804: django.setup(set_prefix=False)

2021-08-07 14:20:53,804:

2021-08-07 14:20:53,804: File "/home/mankavilla/.virtualenvs/django3/lib/python3.6/site-packages/django

/init.py", line 19, in setup

2021-08-07 14:20:53,804: configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)

2021-08-07 14:20:53,804:

2021-08-07 14:20:53,804: File "/home/mankavilla/.virtualenvs/django3/lib/python3.6/site-packages/django/conf/init.py", line 82, in getattr

2021-08-07 14:20:53,804: self._setup(name)

2021-08-07 14:20:53,804: 2021-08-07 14:20:53,805: File "/home/mankavilla/.virtualenvs/django3/lib/python3.6/site-packages/django/conf/init.py", line 69, in _setup

2021-08-07 14:20:53,805: self._wrapped = Settings(settings_module) 2021-08-07 14:20:53,805: 2021-08-07 14:20:53,805: File "/home/mankavilla/.virtualenvs/django3/lib/python3.6/site-packages/django/conf/init.py", line 170, in init

2021-08-07 14:20:53,805: mod = importlib.import_module(self.SETTINGS_MODULE) 2021-08-07 14:20:53,805:

2021-08-07 14:20:53,805: File "/home/mankavilla/django_projects/mysite/mysite/settings.py", line 81, in <module>

2021-08-07 14:20:53,805: 'NAME': BASE_DIR /'db.sqlite3',

in your settings.py you have something like this:

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

yes i do , what to do to fix this

is BASE_DIR a string?

Now I am having this new error

File "/home/mankavilla/.virtualenvs/django3/lib/python3.6/site-packages/django/core/handlers/exception.py", line 47, in inner


    response = get_response(request)


  File "/home/mankavilla/.virtualenvs/django3/lib/python3.6/site-packages/django/core/handlers/base.py", line 181, in _get_response


    response = wrapped_callback(request, *callback_args, **callback_kwargs)


  File "/home/mankavilla/.virtualenvs/django3/lib/python3.6/site-packages/django/views/generic/base.py", line 70, in view


    return self.dispatch(request, *args, **kwargs)


  File "/home/mankavilla/.virtualenvs/django3/lib/python3.6/site-packages/django/views/generic/base.py", line 98, in dispatch


    return handler(request, *args, **kwargs)


  File "/home/mankavilla/django_projects/mysite/home/views.py", line 20, in get
    return render(request, 'home/main.html', context)


  File "/home/mankavilla/.virtualenvs/django3/lib/python3.6/site-packages/django/shortcuts.py", line 19, in render


    content = loader.render_to_string(template_name, context, request, using=using)


  File "/home/mankavilla/.virtualenvs/django3/lib/python3.6/site-packages/django/template/loader.py", line 61, in render_to_string


    template = get_template(template_name, using=using)


  File "/home/mankavilla/.virtualenvs/django3/lib/python3.6/site-packages/django/template/loader.py", line 15, in get_template


    return engine.get_template(template_name)


  File "/home/mankavilla/.virtualenvs/django3/lib/python3.6/site-packages/django/template/backends/django.py", line 34, in get_template


    return Template(self.engine.get_template(template_name), self)


  File "/home/mankavilla/.virtualenvs/django3/lib/python3.6/site-packages/django/template/engine.py", line 143, in get_template


    template, origin = self.find_template(template_name)


  File "/home/mankavilla/.virtualenvs/django3/lib/python3.6/site-packages/django/template/engine.py", line 125, in find_template


    template = loader.get_template(name, skip=skip)


  File "/home/mankavilla/.virtualenvs/django3/lib/python3.6/site-packages/django/template/loaders/base.py", line 24, in get_template


    contents = self.get_contents(origin)


  File "/home/mankavilla/.virtualenvs/django3/lib/python3.6/site-packages/django/template/loaders
/filesystem.py", line 23, in get_contents


    with open(origin.name, encoding=self.engine.file_charset) as fp:


NotADirectoryError: [Errno 20] Not a directory: '/home/mankavilla/django_projects/mysite/db.sqlite3
/home/main.html'

[edit by admin: formatting]

It looks like you have a broken path in your TEMPLATES Django setting -- one that contains your database filename. The "DIRS" list there should only contain directories containing templates.

How do i fix that ?

Take a look at https://docs.djangoproject.com/en/3.2/ref/settings/#std:setting-TEMPLATES

I'm really sorry guys i tried to fix the BASE_DIR as

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(file)))

but then I got this error again. I am really glad that you have helped me till now and would appreciate some assisstance again.

Error running WSGI application

2021-08-11 12:01:18,073: TypeError: unsupported operand type(s) for /: 'str' and 'str'

2021-08-11 12:01:18,073: File "/var/www/mankavilla_pythonanywhere_com_wsgi.py", line 10, in <module>

2021-08-11 12:01:18,073: application = StaticFilesHandler(get_wsgi_application())

2021-08-11 12:01:18,073: 2021-08-11 12:01:18,073: File "/home/mankavilla/.virtualenvs/django3/lib/python3.6/site-packages/django

/core/wsgi.py", line 12, in get_wsgi_application

2021-08-11 12:01:18,073: django.setup(set_prefix=False) 2021-08-11 12:01:18,074: 2021-08-11 12:01:18,074: File "/home/mankavilla/.virtualenvs/django3/lib/python3.6/site-packages/django

/init.py", line 19, in setup

2021-08-11 12:01:18,074: configure_logging(settings.LOGGING_CONFIG, settings.LOGGING) 2021-08-11 12:01:18,074: 2021-08-11 12:01:18,074: File "/home/mankavilla/.virtualenvs/django3/lib/python3.6/site-packages/django

/conf/init.py", line 82, in getattr

2021-08-11 12:01:18,075: self._setup(name) 2021-08-11 12:01:18,075: 2021-08-11 12:01:18,075: File "/home/mankavilla/.virtualenvs/django3/lib/python3.6/site-packages/django/conf/init.py", line 69, in _setup

2021-08-11 12:01:18,075: self._wrapped = Settings(settings_module) 2021-08-11 12:01:18,075: 2021-08-11 12:01:18,075: File "/home/mankavilla/.virtualenvs/django3/lib/python3.6/site-packages/django/conf/init.py", line 170, in init

2021-08-11 12:01:18,075: mod = importlib.import_module(self.SETTINGS_MODULE) 2021-08-11 12:01:18,076:

2021-08-11 12:01:18,076: File "/home/mankavilla/django_projects/mysite/mysite/settings.py", line 16, in <module>

2021-08-11 12:01:18,076: db_path = BASE_DIR / 'db.sqlite3'

You can't just use BASE_DIR / 'db.sqlite3' to mean that you want to append 3 strings. That says divide BASE_DIR by 'db.sqlite3', which is nonsense. Use db_path = f"{BASE_DIR}/db.sqlite3"