OSError django after chmod - django

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.

Related

django nginx DisallowedHost

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']

Django: cannot import name resolve_url

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 !!!

Permission Denied IOError

I have a Django application which saves a file in /opt/Webapp/userfiles/but Apache will not permit this.
In my settings file I have:
MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'userfiles')
but I have also tried with
MEDIA_ROOT = '/opt/Webapp/userfiles'
The full error is:
IOError at /jobs/new
[Errno 13] Permission denied: u'/opt/Webapp/userfiles/770976f582c9a40152505b9e456bfd2d547ec9e7353c766f1c0e0e9a.py'
Request Method: POST
Request URL: https://10.5.1.133/jobs/new
Django Version: 1.7
Exception Type: IOError
Exception Value:
[Errno 13] Permission denied: u'/opt/Webapp/userfiles/770976f582c9a40152505b9e456bfd2d547ec9e7353c766f1c0e0e9a.py'
Exception Location: /opt/Webapp/jobs/views.py in upload, line 188
Python Executable: /usr/bin/python
Python Version: 2.7.6
Python Path:
['/opt/Webapp',
'/opt/.virtualenvs/smart/lib/python2.7/site-packages/django_admin_tools-0.5.1-py2.7.egg',
'/opt/.virtualenvs/smart/lib/python27.zip',
'/opt/.virtualenvs/smart/lib/python2.7',
'/opt/.virtualenvs/smart/lib/python2.7/plat-linux2',
'/opt/.virtualenvs/smart/lib/python2.7/lib-tk',
'/opt/.virtualenvs/smart/lib/python2.7/lib-old',
'/opt/.virtualenvs/smart/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7',
'/usr/local/lib/python2.7/plat-linux2',
'/usr/local/lib/python2.7/lib-tk',
'/opt/.virtualenvs/smart/lib/python2.7/site-packages']
Change permissions of directory with chmod and shown commands. Or change your directory. I don't think that /opt is the best place for such files.
https://help.ubuntu.com/community/FilePermissions - Understanding and Using File Permissions

Django 1.6 IOError

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

When upload files to Amazon S3, Django raise OSError: Permission denied

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