开发者

DatabaseError: Unable to open db file, but only for Django admin

This may be the strangest problem in my 4 years with Django.

My site is working alright locally. In production environment it also runs fine, except, when I try to access the admin site, I get a server error which is an "OperationalError: unable to open database file" in the Apache error log.

The DB file is world writable and the path in the settings are absolute. The production environment is Ubuntu Lucid / Python 2.6 / Sqlite3. I tried both with Django 1.2.4 and 1.3 beta.

The weird part is, I can syncdb on server. It creat开发者_如何转开发es the tables and the admin user. I can access the site without problem. I can run shell and create content within python prompt. The site is browsable. It is only when I access admin, I get this error.

I have no basis left for any reasoning. Any help is greatly appreciated.

ps: The error is raised at Apache level, not from Django. The Django traceback is in Apache error log, which reads DatabaseError: unable to open database file.


A stupid guess.

Which user is running apache?

I know it's strange that the rest of the site works, but double-check your sqlite db is reachable and read-writable from the user Apache is running as!


sudo chown www-data /var/www/yourproject/db.sqlite3

this will do the trick(set the user to Apache)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜