I got main problem in my project,actually Django db.sqlite3 database is not connected with apache server. that’s why when i open my site.I got this error
OperationalError at /
attempt to write a readonly database

So please tell me its solution.
How to connect db.sqlite with apache server in django app on ubuntu.

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.

×
1 answer

Hi there @akshaykoshti401,

Can you share the exact database configuration that you are using in your settings.py file?

Usually, in order to configure SQLite with Django, you need to do the following:

  • First install SQLite:
sudo apt install sqlite3
  • Update your settings.py and adjust these 2 lines:
DATABASE_ENGINE = 'sqlite3'
DATABASE_NAME = '/path/to/your/project/yourdb'
  • Then run your migrations
python manage.py migrate

Another thing that I could suggest is, rather than using SQLite is to use PostgreSQL, you can take a look at this step by step tutorial on how to configure that:

https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-18-04

Hope that this helps!
Regards,
Bobby

by Justin Ellingwood
Django is a powerful web framework that can help you get your Python application or website off the ground. Django includes a simplified development server for testing your code locally, but for anything even slightly production related, a more secure and powerful web server...
Submit an Answer