Environment:
Request Method: GET
Request URL: http://abampdb.......nust.edu.pk:83/
Django Version: 4.0.2
Python Version: 3.9.12
Installed Applications:
['abampdb.apps.AmpdbConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback (most recent call last):
File "/home/abampdb/projectdir/venv_name/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/home/abampdb/projectdir/venv_name/lib/python3.9/site-packages/django/utils/deprecation.py", line 125, in __call__
response = self.process_request(request)
File "/home/abampdb/projectdir/venv_name/lib/python3.9/site-packages/django/middleware/common.py", line 48, in process_request
host = request.get_host()
File "/home/abampdb/projectdir/venv_name/lib/python3.9/site-packages/django/http/request.py", line 135, in get_host
raise DisallowedHost(msg)
Exception Type: DisallowedHost at /
Exception Value: Invalid HTTP_HOST header: 'abampdb.......t.edu.pk:83'. You may need to add 'abampdb...........du.pk' to ALLOWED_HOSTS.
I have used nginx and gunicorn for the deployement from this link https://djangocentral.com/deploy-django-with-nginx-gunicorn-postgresql-and-lets-encrypt-ssl-on-ubuntu/.
I have edited the settings.py also with the domain name in the Allowed Host but still getting the same error and after editing i have also run the gunicorn restart command and nginx reload command. here is my
Related
I'm running my website on Django 3.2. I read in Django’s cache framework that MemcachedCache and python-memcached are deprecated. I installed pymemcache==3.5.0 on my staging server and changed to CACHE_URL=pymemcache://127.0.0.1:11211 in env.ini. But if I uninstall python-memcached with pip I receive an error message, that indicates that MemcachedCache is still used by my code, and it fails on import memcache.
My code uses the following imports:
from django.core.cache import cache
from django.core.cache.backends.base import DEFAULT_TIMEOUT
How do I replace MemcachedCache with PyMemcacheCache so that MemcachedCache will not be used in my code?
I'm using django-environ==0.8.1 and CACHES is defined in my settings:
CACHES = {
'default': env.cache()
}
env is defined as environ.Env().
My Traceback:
Environment:
Request Method: GET
Request URL: https://<...>
Django Version: 3.2.10
Python Version: 3.8.12
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'crispy_forms',
'friendship',
'rules.apps.AutodiscoverRulesConfig',
'sorl.thumbnail',
'speedy.core.base',
'speedy.core.accounts',
'speedy.core.blocks',
'speedy.core.uploads',
'speedy.core.messages',
'speedy.core.profiles',
'speedy.core.friends',
'speedy.core.about',
'speedy.core.privacy',
'speedy.core.terms',
'speedy.net.accounts',
'speedy.match.accounts',
'speedy.match.likes',
'speedy.composer.accounts',
'speedy.mail.accounts',
'speedy.core.contact_by_form',
'speedy.match.profiles',
'speedy.match.matches']
Installed Middleware:
['speedy.core.base.middleware.SessionCookieDomainMiddleware',
'speedy.core.base.middleware.RemoveExtraSlashesMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.contrib.sites.middleware.CurrentSiteMiddleware',
'django.middleware.locale.LocaleMiddleware',
'speedy.core.base.middleware.LocaleDomainMiddleware',
'speedy.core.base.middleware.EnsureCachesMiddleware',
'speedy.core.base.middleware.UpdateSessionAuthHashMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'speedy.core.accounts.middleware.SiteProfileMiddleware']
Traceback (most recent call last):
File "<...>/env/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "<...>/./speedy/core/base/middleware.py", line 139, in __call__
block_managers.ensure_caches(user=request.user)
File "<...>/./speedy/core/blocks/managers.py", line 46, in ensure_caches
blocked_entities = cache_manager.cache_get(blocked_key, sliding_timeout=DEFAULT_TIMEOUT)
File "<...>/./speedy/core/base/cache_manager.py", line 21, in cache_get
wrapped_value = cache.get(key, default=DEFAULT_VALUE, version=version)
File "<...>/env/lib/python3.8/site-packages/django/utils/connection.py", line 15, in __getattr__
return getattr(self._connections[self._alias], item)
File "<...>/env/lib/python3.8/site-packages/django/utils/connection.py", line 62, in __getitem__
conn = self.create_connection(alias)
File "<...>/env/lib/python3.8/site-packages/django/core/cache/__init__.py", line 44, in create_connection
return backend_cls(location, params)
File "<...>/env/lib/python3.8/site-packages/django/core/cache/backends/memcached.py", line 181, in __init__
import memcache
Exception Type: ModuleNotFoundError at /matches/
Exception Value: No module named 'memcache'
My repository: https://github.com/speedy-net/speedy-net
Update: I checked the email message I received for debugging and I see that the CACHES in settings is equal to {'default': {'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', 'LOCATION': '127.0.0.1:11211'}}.
I submitted an issue (possibly a bug) on https://github.com/joke2k/django-environ/issues/359
I don't know why, but the way I restarted my server during deploy doesn't refresh env.ini, and the server remembers the old settings. If I restart my server with sudo reboot, with the same settings, then CACHES is equal to {'default': {'BACKEND': 'django.core.cache.backends.memcached.PyMemcacheCache', 'LOCATION': '127.0.0.1:11211'}} and the site works properly. And I confirmed that if I put dummy values in env.ini then the site doesn't work at all. But only if I restart my server with sudo reboot.
I am trying to run my Django server and I am facing the following issue. So, I am pretty new on Django, then Let me know if you need any additional information. This code is really complex to me and I am challenging myself to run multiples applications at the same time.
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 2.2.2
Python Version: 3.6.4
Installed Applications:
['registration',
'mailqueue',
'el_pagination',
'social_django',
'django_inlinecss',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'main',
'users']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'social_django.middleware.SocialAuthExceptionMiddleware']
Traceback:
File "/home/rnominato/anaconda3/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
34. response = get_response(request)
File "/home/rnominato/anaconda3/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
115. response = self.process_exception_by_middleware(e, request)
File "/home/rnominato/anaconda3/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
113. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/rnominato/PycharmProjects/Liben_Feb_2020/main/decorators.py" in wrap
20. mode = Mode.objects.get(id=1)
File "/home/rnominato/anaconda3/lib/python3.6/site-packages/django/db/models/manager.py" in manager_method
82. return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/rnominato/anaconda3/lib/python3.6/site-packages/django/db/models/query.py" in get
408. self.model._meta.object_name
Exception Type: DoesNotExist at /
Exception Value: Mode matching query does not exist.
I am trying to run the bradtraversy simple todo list django code on my raspberry pi and have run into the following error. I have run into the following traceback:
Environment:
Request Method: GET
Request URL: HIDDEN
Django Version: 1.11.11
Python Version: 2.7.13
Installed Applications:
['todos.apps.TodosConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/exception.py" in inner
41. response = get_response(request)
File "/usr/local/lib/python2.7/dist-packages/django/utils/deprecation.py" in __call__
138. response = self.process_request(request)
File "/usr/local/lib/python2.7/dist-packages/django/middleware/common.py" in process_request
57. host = request.get_host()
File "/usr/local/lib/python2.7/dist-packages/django/http/request.py" in get_host
105. if domain and validate_host(domain, allowed_hosts):
File "/usr/local/lib/python2.7/dist-packages/django/http/request.py" in validate_host
579. if pattern == '*' or is_same_domain(host, pattern):
File "/usr/local/lib/python2.7/dist-packages/django/utils/http.py" in is_same_domain
291. pattern = pattern.lower()
Exception Type: AttributeError at /
Exception Value: 'list' object has no attribute 'lower'
I am fairly new to Django but thought I made all the correct adjustments to match my system specifics. I updated the settings file to match my allowed hosts and database setting and used the "python manage.py migrate" command to bring over migrations.
Any thoughts or help would be greatly appreciated. Thank you
I am working in Django 1.8 and Python 3.5
I have 3 apps -> mainpage,login,signup and the directory is given in the picture
I am trying to import mainpage/models.py in login/forms.py But when I do it it give If there is anything else you people want me to post tell me what do I do in the comments ?
See Image
and yes
Please I have read this already but not working.Thanks in advance
TRACEBACK
Environment:
Request Method: GET
Request URL: http://localhost:8000/login
Django Version: 1.8
Python Version: 3.5.4
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'mainpage',
'signup',
'login',
'rest_framework',
'corsheaders')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware')
Traceback:
File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\handlers\base.py" in get_response
108. response = middleware_method(request)
File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\site-packages\django\middleware\common.py" in process_request
74. if (not urlresolvers.is_valid_path(request.path_info, urlconf) and
File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\urlresolvers.py" in is_valid_path
647. resolve(path, urlconf)
File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\urlresolvers.py" in resolve
522. return get_resolver(urlconf).resolve(path)
File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\urlresolvers.py" in resolve
368. sub_match = pattern.resolve(new_path)
File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\urlresolvers.py" in resolve
240. return ResolverMatch(self.callback, args, kwargs, self.name)
File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\urlresolvers.py" in callback
247. self._callback = get_callable(self._callback_str)
File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\urlresolvers.py" in get_callable
106. mod = import_module(mod_name)
File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\importlib\__init__.py" in import_module
126. return _bootstrap._gcd_import(name[level:], package, level)
File "C:\Users\vaibhav2\PycharmProjects\MajorProject\src\login\views.py" in <module>
2. from .forms import UserLoginForm
File "C:\Users\vaibhav2\PycharmProjects\MajorProject\src\login\forms.py" in <module>
2. from MajorProject.src.signup.models import allusers1
Exception Type: ImportError at /login
Exception Value: No module named 'MajorProject'
EDIT
According to #Alasdair's answer the error that is coming is this
ImportError at /login
No module named 'src.signup'
Environment:
Request Method: GET
Request URL: http://localhost:8000/login
Django Version: 1.8
Python Version: 3.5.4
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'mainpage',
'signup',
'login',
'rest_framework',
'corsheaders')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware')
Traceback:
File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\handlers\base.py" in get_response
108. response = middleware_method(request)
File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\site-packages\django\middleware\common.py" in process_request
74. if (not urlresolvers.is_valid_path(request.path_info, urlconf) and
File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\urlresolvers.py" in is_valid_path
647. resolve(path, urlconf)
File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\urlresolvers.py" in resolve
522. return get_resolver(urlconf).resolve(path)
File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\urlresolvers.py" in resolve
368. sub_match = pattern.resolve(new_path)
File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\urlresolvers.py" in resolve
240. return ResolverMatch(self.callback, args, kwargs, self.name)
File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\urlresolvers.py" in callback
247. self._callback = get_callable(self._callback_str)
File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\urlresolvers.py" in get_callable
106. mod = import_module(mod_name)
File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\importlib\__init__.py" in import_module
126. return _bootstrap._gcd_import(name[level:], package, level)
File "C:\Users\vaibhav2\PycharmProjects\MajorProject\src\login\views.py" in <module>
2. from .forms import UserLoginForm
File "C:\Users\vaibhav2\PycharmProjects\MajorProject\src\login\forms.py" in <module>
3. from src.signup.models import allusers1
Exception Type: ImportError at /login
Exception Value: No module named 'src.signup'
signup is in the project directory (the one that contains manage.py). Therefore the import should be simply:
from signup.models import allusers1
Very specific stuff. I'm running a Bitnami Django stack cloud VM on Amazon. On two different "regular" machines, I could install requests by running sudo pip install requests, but it seems that Bitname uses it's own specific structure, and something is going wrong when installing requests that way. It can also be related to issue #2028, but it was fixed long time ago.
I have the following traceback:
Environment:
Request Method: GET
Request URL: http://54.94.226.137/
Django Version: 1.7.7
Python Version: 2.7.6
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'vz_base',
'vz_api',
'vz_admin',
'vz_user')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware')
Traceback:
File "/opt/bitnami/python/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
98. resolver_match = resolver.resolve(request.path_info)
File "/opt/bitnami/python/lib/python2.7/site-packages/django/core/urlresolvers.py" in resolve
343. for pattern in self.url_patterns:
File "/opt/bitnami/python/lib/python2.7/site-packages/django/core/urlresolvers.py" in url_patterns
372. patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/opt/bitnami/python/lib/python2.7/site-packages/django/core/urlresolvers.py" in urlconf_module
366. self._urlconf_module = import_module(self.urlconf_name)
File "/opt/bitnami/python/lib/python2.7/importlib/__init__.py" in import_module
37. __import__(name)
File "/opt/bitnami/apps/django/django_projects/ProjetoVigZul/ProjetoVigZul/urls.py" in <module>
5. from vz_api import urls as api_urls
File "/opt/bitnami/apps/django/django_projects/ProjetoVigZul/vz_api/urls.py" in <module>
8. from vz_api import views
File "/opt/bitnami/apps/django/django_projects/ProjetoVigZul/vz_api/views.py" in <module>
14. from vz_api.dguard import DGuardManager, DGuardIntegrationException
File "/opt/bitnami/apps/django/django_projects/ProjetoVigZul/vz_api/dguard.py" in <module>
5. import requests, json
File "/opt/bitnami/python/lib/python2.7/site-packages/requests/__init__.py" in <module>
58. from . import utils
File "/opt/bitnami/python/lib/python2.7/site-packages/requests/utils.py" in <module>
25. from . import certs
Exception Type: ImportError at /
Exception Value: cannot import name certs
Website is live at http://54.94.226.137/, if anyone is interested.
sudo pip install --upgrade requests
solved that for me