Forums

deploy error

hi igot this error trying to debug the error

(myvirtualenv) 10:08 ~/greatkart-django-main (master)$ python -i /var/www/www_my_domain_com_wsgi.py

and in error log i got this :

Internal Server Error: /
Traceback (most recent call last):
  File "/home/faramarz1/.virtualenvs/ven/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/home/faramarz1/.virtualenvs/ven/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/faramarz1/greatkart-django-main/greatkart/views.py", line 12, in home
    return render(request, 'home.html', context)
  File "/home/faramarz1/.virtualenvs/ven/lib/python3.9/site-packages/django/shortcuts.py", line 19, in render
    content = loader.render_to_string(template_name, context, request, using=using)
  File "/home/faramarz1/.virtualenvs/ven/lib/python3.9/site-packages/django/template/loader.py", line 61, in render_to_string
    template = get_template(template_name, using=using)
  File "/home/faramarz1/.virtualenvs/ven/lib/python3.9/site-packages/django/template/loader.py", line 19, in get_template
    raise TemplateDoesNotExist(template_name, chain=chain)
django.template.exceptions.TemplateDoesNotExist: home.html
2023-04-26 22:20:27,653: Internal Server Error: /
Traceback (most recent call last):
  File "/home/faramarz1/.virtualenvs/ven/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/home/faramarz1/.virtualenvs/ven/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/faramarz1/greatkart-django-main/greatkart/views.py", line 12, in home
    return render(request, 'home.html', context)
  File "/home/faramarz1/.virtualenvs/ven/lib/python3.9/site-packages/django/shortcuts.py", line 19, in render
    content = loader.render_to_string(template_name, context, request, using=using)
  File "/home/faramarz1/.virtualenvs/ven/lib/python3.9/site-packages/django/template/loader.py", line 61, in render_to_string
    template = get_template(template_name, using=using)
  File "/home/faramarz1/.virtualenvs/ven/lib/python3.9/site-packages/django/template/loader.py", line 19, in get_template
    raise TemplateDoesNotExist(template_name, chain=chain)
django.template.exceptions.TemplateDoesNotExist: home.html
2023-04-26 22:21:08,113: Internal Server Error: /
Traceback (most recent call last):
  File "/home/faramarz1/.virtualenvs/ven/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/home/faramarz1/.virtualenvs/ven/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/faramarz1/greatkart-django-main/greatkart/views.py", line 12, in home
    return render(request, 'home.html', context)
  File "/home/faramarz1/.virtualenvs/ven/lib/python3.9/site-packages/django/shortcuts.py", line 19, in render
    content = loader.render_to_string(template_name, context, request, using=using)
  File "/home/faramarz1/.virtualenvs/ven/lib/python3.9/site-packages/django/template/loader.py", line 61, in render_to_string
    template = get_template(template_name, using=using)
  File "/home/faramarz1/.virtualenvs/ven/lib/python3.9/site-packages/django/template/loader.py", line 19, in get_template
    raise TemplateDoesNotExist(template_name, chain=chain)
django.template.exceptions.TemplateDoesNotExist: home.html
2023-04-26 22:21:10,836: Not Found: /favicon.ico
2023-05-10 14:14:10,586: Internal Server Error: /
Traceback (most recent call last):
  File "/home/faramarz1/.virtualenvs/ven/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/home/faramarz1/.virtualenvs/ven/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/faramarz1/greatkart-django-main/greatkart/views.py", line 12, in home
    return render(request, 'home.html', context)
  File "/home/faramarz1/.virtualenvs/ven/lib/python3.9/site-packages/django/shortcuts.py", line 19, in render
    content = loader.render_to_string(template_name, context, request, using=using)
  File "/home/faramarz1/.virtualenvs/ven/lib/python3.9/site-packages/django/template/loader.py", line 61, in render_to_string
    template = get_template(template_name, using=using)
  File "/home/faramarz1/.virtualenvs/ven/lib/python3.9/site-packages/django/template/loader.py", line 19, in get_template
    raise TemplateDoesNotExist(template_name, chain=chain)
django.template.exceptions.TemplateDoesNotExist: home.html
2023-05-10 14:14:27,231: Internal Server Error: /
Traceback (most recent call last):
  File "/home/faramarz1/.virtualenvs/ven/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/home/faramarz1/.virtualenvs/ven/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/faramarz1/greatkart-django-main/greatkart/views.py", line 12, in home
    return render(request, 'home.html', context)
  File "/home/faramarz1/.virtualenvs/ven/lib/python3.9/site-packages/django/shortcuts.py", line 19, in render
    content = loader.render_to_string(template_name, context, request, using=using)
  File "/home/faramarz1/.virtualenvs/ven/lib/python3.9/site-packages/django/template/loader.py", line 61, in render_to_string
    template = get_template(template_name, using=using)
  File "/home/faramarz1/.virtualenvs/ven/lib/python3.9/site-packages/django/template/loader.py", line 19, in get_template
    raise TemplateDoesNotExist(template_name, chain=chain)
django.template.exceptions.TemplateDoesNotExist: home.html
2023-05-10 14:14:27,719: Not Found: /favicon.ico
2023-05-10 14:14:30,089: Internal Server Error: /
Traceback (most recent call last):
  File "/home/faramarz1/.virtualenvs/ven/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/home/faramarz1/.virtualenvs/ven/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/faramarz1/greatkart-django-main/greatkart/views.py", line 12, in home
    return render(request, 'home.html', context)
  File "/home/faramarz1/.virtualenvs/ven/lib/python3.9/site-packages/django/shortcuts.py", line 19, in render
    content = loader.render_to_string(template_name, context, request, using=using)
  File "/home/faramarz1/.virtualenvs/ven/lib/python3.9/site-packages/django/template/loader.py", line 61, in render_to_string
    template = get_template(template_name, using=using)
  File "/home/faramarz1/.virtualenvs/ven/lib/python3.9/site-packages/django/template/loader.py", line 19, in get_template
    raise TemplateDoesNotExist(template_name, chain=chain)
django.template.exceptions.TemplateDoesNotExist: home.html
2023-05-10 14:14:41,748: Internal Server Error: /
Traceback (most recent call last):
  File "/home/faramarz1/.virtualenvs/ven/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/home/faramarz1/.virtualenvs/ven/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/faramarz1/greatkart-django-main/greatkart/views.py", line 12, in home
    return render(request, 'home.html', context)
  File "/home/faramarz1/.virtualenvs/ven/lib/python3.9/site-packages/django/shortcuts.py", line 19, in render
    content = loader.render_to_string(template_name, context, request, using=using)
  File "/home/faramarz1/.virtualenvs/ven/lib/python3.9/site-packages/django/template/loader.py", line 61, in render_to_string
    template = get_template(template_name, using=using)
  File "/home/faramarz1/.virtualenvs/ven/lib/python3.9/site-packages/django/template/loader.py", line 19, in get_template
    raise TemplateDoesNotExist(template_name, chain=chain)
django.template.exceptions.TemplateDoesNotExist: home.html
2023-05-10 14:14:45,346: Internal Server Error: /
Traceback (most recent call last):
  File "/home/faramarz1/.virtualenvs/ven/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/home/faramarz1/.virtualenvs/ven/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/faramarz1/greatkart-django-main/greatkart/views.py", line 12, in home
    return render(request, 'home.html', context)
  File "/home/faramarz1/.virtualenvs/ven/lib/python3.9/site-packages/django/shortcuts.py", line 19, in render
    content = loader.render_to_string(template_name, context, request, using=using)
  File "/home/faramarz1/.virtualenvs/ven/lib/python3.9/site-packages/django/template/loader.py", line 61, in render_to_string
    template = get_template(template_name, using=using)
  File "/home/faramarz1/.virtualenvs/ven/lib/python3.9/site-packages/django/template/loader.py", line 19, in get_template
    raise TemplateDoesNotExist(template_name, chain=chain)
django.template.exceptions.TemplateDoesNotExist: home.html

and this at before i try debug from above

  super().__init__(*args, **kwargs2)
django.db.utils.OperationalError: (1045, "Access denied for user 'faramarz1$default'@'10.0.0.198' (using password: YES)")
^C

[edit by admin: formatting]

It looks like you have two problems there:

  • The template not being found. Where is your template home.html, and what template path settings do you have in your settings.py.
  • Your database connection not working. Where are you defining the MySQL database password, and is it exactly the same as the one in .my.cnf in your home directory?

i change my password to what it is in .my.cnf and save it

https://www.pythonanywhere.com/user/faramarz1/files/home/faramarz1/greatkart-django-main/templates/home.html

BASE_DIR = Path(file).resolve(strict=True).parent.parent

and it is work well in local but under python 3.9.6

Where is the file that defines the BASE_DIR?

https://www.pythonanywhere.com/user/faramarz1/files/home/faramarz1/greatkart-django-main/templates/base.html?edit

No, the BASE_DIR definition is in a file. Where is that file?

https://www.pythonanywhere.com/user/faramarz1/files/home/faramarz1/greatkart-django-main/templates

I think Glenn was asking about the file containing the definition of BASE_DIR, so probably the settings.py. Also, do you define TEMPLATES in your settings?

BASE_DIR = Path(file).resolve(strict=True).parent.parent

TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': ['templates'], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', 'category.context_processors.menu_links', 'carts.context_processors.counter', ], }, }, ]

this is from setting.py is this what you mean and it working ok on local host
but on local it is working with python 3.9.6 and hear in your host python version is 3.10 do

how can i give password and user name to you so you can see for yourself codes directly

You need to build absolute templates directory from BASE_DIR.

  1. first ?

how to change python version inside virtualenv

2 ?

You need to build absolute templates directory from BASE_DIR. how to do that give me example

you mean like this ? BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(file)))

Ad 1. You'd need to create a new virtual env with a specific Python version Ad 2. Or you could try to use a hardcoded string with the path (something like "/home/faramarz1/..."), just to start debugging, and if that would work, you can use more portable approach, as you suggested.

mkvirtualenv myvirtualenv --python=python3.9.6 RuntimeError: failed to find interpreter for Builtin discover of python_spec='python3.9.6'

You don't need to specify the full Python version. Just use this:

mkvirtualenv myvirtualenv --python=python3.9

django.db.utils.OperationalError: (1045, "Access denied for user 'faramarz1$default'@'10.0.0.198' (using password: NO)")

i

DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'greatkart-django-main', 'USER': 'faramarz1$default',

'PASSWORD': 'TT85@a45@@A',

    'HOST':'faramarz1.mysql.pythonanywhere-services.com',

}

} i try to comment it after that not working also check at .my.cnf and it is the same as you see hear

[client] password = "TT85@a45@@A"

faramarz1$default is the database name not the username that is is faramarz1, also greatkart-django-main' is not a valid database name on PythonAnywhere.

django.db.utils.NotSupportedError: MySQL 8 or later is required (found 5.7.41). i install pip install mysqlclient and when i wnat to python manage.py migrate i got this error

It looks like your account was created (and your database was created) before we supported MySQL 8. We can migrate your data over to a MySQL 8 server, but there will be a bit of downtime for you while we do it. Would you like us to go ahead with that?

yes please do thank you

We'll do that today and let you know once it's done