Django管理员后端"操作错误"尝试编写只读数据库

Dee*_*pak 1 python sqlite django nginx gunicorn

这个问题似乎已被多次询问,但我检查的所有解决方案都还没有为我工作.我在nginx安装了Django 1.6.1的Ubuntu 14.04服务器上运行.我正在尝试将默认的django管理员后端用于项目(通常在localhost/admin /).

我遇到的问题是 OperationalError at /admin/ attempt to write a readonly database

(更改当我更改db.sqlite3文件的chmod权限时,错误现在读取OperationalError at /admin/ unable to open database file 但我已经检查了Django Newbie Mistakes网站上的每个选项以获得答案而没有骰子)

一些答案谈到了生成的数据库文件的r + w + x权限,db.sqlite3据我所知甚至777在db文件中没有做任何事情所以我保留了它656.

至于我可以告诉django项目的工作找到(所有页面呈现正常,/ admin页面呈现没有CSS.当我尝试使用localhost/admin /登录并单击提交时,我得到带有错误的django调试页面).他们都归root:root.我已经尝试更改每个文件和目录的权限,www-data:www-data但没有.

我甚至尝试更改settings.py以获得db的绝对路径而不是 os.path.join(BASE_DIR, 'db.sqlite3')

我认为这归结为所有权问题但我会提供任何帮助.

Dee*_*pak 6

After all that hassle and 2+ hours of banging my head against a wall, the answer for the archives...

I was using gunicorn, I took a cookie cutter set up from Digital Ocean which made the user django. I thought it the cookie cutter approach would be a shortcut which was easy to modify and skipped the boring bits. It turns out in /etc/init/gunicorn.conf setuid and setgid was set to the user django. My fault for not reading the documentation and assuming these meant little.

If you are having this problem either delete setuid or setgid or set them to www-data.