Question

Django can't get access to sqlite3 database

I am currently running a server instance of the one-click install option for Django Ubuntu 14.04.

This server is running a Django app using NGINX, sqlite3, and gunicorn.

I set up letsencrypt properly and it is used to serve my website with ssl.

I deleted all of the files in /home/django/dango_project/ and replaced them with my own.

When I load my website, everything works fine, except for my admin site.

I am able to log in to the admin site when I run the django_project locally, but it isn’t working when the project is in production at my website.

You can verify that my db.sqlite3 file exists and contains posts by going to kensch.com/blog.

With debug disabled, my website gives a Server Error (500) after I log in to my admin site.

With debug enabled, my website gives OperationalError at /admin/ attempt to write a readonly database after logging into the admin site.

I have been trying to get into my admin site for nearly 5 hours now, no google searches are helping.

I appreciate any help in advance!

Subscribe
Share

sir when i upload sqlite3 on django app hosted on digital ocean platform then data of the database i uploaded get deleted i am not able to understand what is the problem please suggest me the solution thanks in advance


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

open puTTy once you link the ip address and login cd into file location ie cd /home/django/django_project/ then enter

chown django:django db.sqlite3

open puTTy once you link the ip address and login cd into file location ie cd /home/django/django_project/ then enter

chown django:django db.sqlite3

open puTTy once you link the ip address and login cd into file location ie cd /home/django/django_project/ then enter

chown django:django db.sqlite3

open puTTy once you link the ip address and login cd into file location ie cd /home/django/django_project/ then enter

chown django:django db.sqlite3

open puTTy once you link the ip address and login cd into file location ie cd /home/django/django_project/ then enter

chown django:django db.sqlite3

Through research I found out that someone answered–and it worked for me–the solution perfectly (sorry, I did so much research that I do not remember who or where was it):

cd project-folder sudo chown www-data .

Mind the space between www-data and the period.

Best,

Laurentino

I had the same problem which gave me a lot of headache but this small line of code ‘chmod a+w db.sqlite3’ performed the magic and it worked perfectly. Thank you santopolsky

The solution I found is very simple: you just need to add writing permission to the users of the database. Go to the folder of you db.sqlite3 and run chmod a+w db.sqlite3 to add writing permission for all users. Then run service gunicorn restart if the changes do not take effect. Worked for me.

Hello, Here my solution:

root@fiq:/home/django/django_project# chmod 777 db.sqlite3

root@fiq:/home/django/django_project# cd …

root@fiq:/home/django# chmod 777 *

Go to <your_website/admin> put username and password… That’s it.

Where you able to figure anything out? I just ran into the same problem.