I was doing 2nd part of django tutorial when i got this error after going to http://127.0.0.1:8000/admin/:
ImportError at /admin/
cannot import name resolve_url
Request Method: GET
Request URL: http://127.0.0.1:8000/admin/
Django Version: 1.7.1
Exception Type: ImportError
Exception Value:
cannot import name resolve_url
Exception Location: /usr/local/lib/python2.7/dist-packages/django/contrib/auth/views.py in <module>, line 8
Python Executable: /usr/bin/python
Python Version: 2.7.6
Python Path:
['/home/xxx/Projects/mysite',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages/PILcompat',
'/usr/lib/python2.7/dist-packages/gtk-2.0',
'/usr/lib/python2.7/dist-packages/ubuntu-sso-client']
Server time: Fri, 2 Jan 2015 22:44:47 +0000
I work on:
Ubuntu 14.04.1 LTS 64-bit
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Any idea how it fix?
It is not your mistake , it happened because of improper installation of Django.
My solution is go to the location where django folder is situated.
which is basically
/usr/local/lib/python2.7/dist-packages
From there remove the folder.
sudo rm -rf django
Reinstall Django
sudo pip install Django==1.7
or any version which u want.
Enjoy !!!
Related
i'm using aws ubuntu instance and nginx
i tried to reach my app and i get this error :
DisallowedHost at /
Invalid HTTP_HOST header: '34.227.190.72'. You may need to add '34.227.190.72' to ALLOWED_HOSTS.
Request Method: GET
Request URL: http://34.227.190.72/
Django Version: 4.0.4
Exception Type: DisallowedHost
Exception Value:
Invalid HTTP_HOST header: '34.227.190.72'. You may need to add '34.227.190.72' to ALLOWED_HOSTS.
Exception Location: /home/ubuntu/env/lib/python3.8/site-packages/django/http/request.py, line 149, in get_host
Python Executable: /home/ubuntu/env/bin/python3
Python Version: 3.8.10
Python Path:
['/home/ubuntu/authentication',
'/home/ubuntu/env/bin',
'/usr/lib/python38.zip',
'/usr/lib/python3.8',
'/usr/lib/python3.8/lib-dynload',
'/home/ubuntu/env/lib/python3.8/site-packages']
Server time: Tue, 31 May 2022 10:46:53 +0000
i tried to add my public address to ALLOWED_HOSTS in setting.py file but it doesn't work
my setting.py file :
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ['34.227.190.72', 'localhost', '127.0.0.1']
I developed an e-commerce site on my local laptop and the project uses redis and when I run the project from localhost, it works perfectly using the following
r = redis.StrictRedis(host=settings.REDIS_HOST, port=settings.REDIS_PORT, db=settings.REDIS_DB):
REDIS_HOST = 'localhost'
REDIS_PORT = 6379
REDIS_DB = 1
Now, I am trying to deploy the project to python anywhere. I have installed the redis and started the server, changed localhost to myhost.pythonanywhere.com but when I run visit the site I get the following error:
Error 111 connecting to 50.19.109.98:6379. Connection refused.
Request Method: GET
Request URL: http://myhost.pythonanywhere.com/en/4/black-garbage-t-shirt/
Django Version: 1.8.3
Exception Type: ConnectionError
Exception Value:
Error 111 connecting to 50.19.109.98:6379. Connection refused.
Exception Location: /home/dguy/dguy/venv/lib/python3.4/site-packages/redis/connection.py in connect, line 436
Python Executable: /usr/local/bin/uwsgi
Python Version: 3.4.3
Python Path:
['/var/www',
'.',
'',
'/var/www',
'/home/dguy/dguy/venv/lib/python3.4',
'/home/dguy/dguy/venv/lib/python3.4/plat-x86_64-linux-gnu',
'/home/dguy/dguy/venv/lib/python3.4/lib-dynload',
'/usr/lib/python3.4',
'/usr/lib/python3.4/plat-x86_64-linux-gnu',
'/home/dguy/dguy/venv/lib/python3.4/site-packages',
'/home/dguy/dguy',
'/home/dguy']
Server time: Wed, 17 Aug 2016 16:10:56 +0100
Can someone please help me. what are the right configuration.
Redis will not work on PythonAnywhere.
I have an upload system and this morning it was working right but when i came back this afternoon i get this error:
[Errno 13] Permission denied: '/media/media'
Request Method: POST
Request URL: http://localhost:8000/admin/blog/hojas/add/
Django Version: 1.6.1
Exception Type: OSError
Exception Value:
[Errno 13] Permission denied: '/media/media'
Exception Location: /usr/lib/python2.7/os.py in makedirs, line 157
Python Executable: /usr/bin/python
Python Version: 2.7.5
Python Path:
['/home/yabir/Documentos/taqwim/proyecto',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages/PILcompat',
'/usr/lib/python2.7/dist-packages/gtk-2.0',
'/usr/lib/python2.7/dist-packages/ubuntu-sso-client',
'/usr/lib/python2.7/dist-packages/ubuntuone-client',
'/usr/lib/python2.7/dist-packages/ubuntuone-control-panel',
'/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol',
'/home/my_username/projects']
after see it, I procced to give to my folder 755 permissions but it still not working.
I have upgraded my django version from 1.5.2(if i don't remember bad) to 1.6 and now when i execute my project on localhost i get this error:
IOError at /
[Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/httplib2-0.8-py2.7.egg/EGG-INFO/top_level.txt'
Request Method: GET
Request URL: http://localhost:8000/
Django Version: 1.6.1
Exception Type: IOError
Exception Value:
[Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/httplib2-0.8-py2.7.egg/EGG-INFO/top_level.txt'
Exception Location: /usr/local/lib/python2.7/dist-packages/pkg_resources.py in _get, line 1320
Python Executable: /usr/bin/python
Python Version: 2.7.5
It looks like a Permission Error. Try to change the permissions with the chmod command (http://www.thegeekstuff.com/2010/06/chmod-command-examples/).
For example
sudo chmod -R 755 problematic_folder
I use django-s3-folder-storage to integrate S3 in my Django project, it is OK when I run python manage.py collectstatic to upload the static files to the bucket, but when I try to upload a image to the bucket in the admin site, it raise the error Permission denied:
OSError at /admin/picture/picture/1/
[Errno 13] Permission denied: '/media/draw_share_picture'
Request Method: POST
Request URL: http://127.0.0.1:8000/admin/picture/picture/1/
Django Version: 1.3.1
Exception Type: OSError
Exception Value:
[Errno 13] Permission denied: '/media/draw_share_picture'
Exception Location: /home/ragnarok/Projects/drawshare/venv/lib/python2.7/os.py in makedirs, line 157
Python Executable: /home/ragnarok/Projects/drawshare/venv/bin/python
Python Version: 2.7.3
Python Path:
['/home/ragnarok/Projects/drawshare/drawShare',
'/usr/lib/python2.7/site-packages/liquidluck-0.3-py2.7.egg',
'/usr/lib/python2.7/site-packages/houdini.py-0.1.0-py2.7-linux-i686.egg',
'/usr/lib/python2.7/site-packages/misaka-1.0.2-py2.7-linux-i686.egg',
'/usr/lib/python2.7/site-packages/docutils-0.9.1-py2.7.egg',
'/home/ragnarok/Projects/drawshare/venv/lib/python2.7/site-packages/distribute-0.6.27-py2.7.egg',
'/home/ragnarok/Projects/drawshare/venv/lib/python2.7/site-packages/pip-1.1-py2.7.egg',
'/home/ragnarok/Projects',
'/usr/lib/python2.7/site-packages',
'/home/ragnarok/Projects/drawshare/drawShare',
'/usr/lib/python2.7/site-packages/PIL',
'/usr/lib/python2.7/site-packages/gtk-2.0',
'/usr/lib/python2.7/site-packages/setuptools-0.6c11.egg-info',
'/home/ragnarok/Projects/drawshare/venv/lib/python27.zip',
'/home/ragnarok/Projects/drawshare/venv/lib/python2.7',
'/home/ragnarok/Projects/drawshare/venv/lib/python2.7/plat-linux2',
'/home/ragnarok/Projects/drawshare/venv/lib/python2.7/lib-tk',
'/home/ragnarok/Projects/drawshare/venv/lib/python2.7/lib-old',
'/home/ragnarok/Projects/drawshare/venv/lib/python2.7/lib-dynload',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-linux2',
'/usr/lib/python2.7/lib-tk',
'/home/ragnarok/Projects/drawshare/venv/lib/python2.7/site-packages']
Why?
Were you able to get this working, Ragnarok? Try running the django-s3-folder-storage tests from within your app and let me know what you find.
python manage.py test s3_folder_storage