7👍
Basically there are two answers, either user which running server don’t have rights to open database file.
You can try to fix this by:
sudo chown $(whoami):$(whoami) /path/to/dir/db/db.sqlite3
Or you don’t have this file, you can create it by applying migrate command:
./manage.py migrate
10👍
Suffering for a while from the same issue and I believe I have found a solution, finally!
sudo python manage.py runserver
and that did the trick for me.
My permissions were telling me that everything is how it should be. Regardless, I still had to type in sudo at the beginning of the command at the terminal.
- Django __call__() missing 1 required keyword-only argument: 'manager'
- Django CMS malfunction: Site matching query does not exist
- Django global variable
- Django filter through multiple fields in a many-to-many intermediary table
4👍
I had the same problem, just solved it. Make sure www-data (or whatever daemon running your web server) has access to both the db.sqlite3 file, and also the path to it. So:
sudo chown :www-data <project_folder>/
sudo chown :www-data <project_folder>/db.sqlite3
sudo chmod 664 <project_folder>/db.sqlite3
- Django: GenericForeignKey and unique_together
- Rename response fields django rest framework serializer
- Import m2m relation in django-import-export
- Datetime Field Received a Naive Datetime
- Decorators run before function it is decorating is called?
4👍
Just remove the first db in your settings.py file.
You have os.path.join(BASE_DIR, 'db/db.sqlite3')
if you remove the first db
, you’ll have os.path.join(BASE_DIR, 'db.sqlite3')
Your database settings will be
DATABASES = {
'default': dj_database_url.config(
default="sqlite:///{}".format(
os.path.join(BASE_DIR, 'db.sqlite3')
)
)
}
- Easy Way to Escape Django Template Variables
- How to setup APScheduler in a Django project?
- How to properly runserver on different settings for Django?
- Datetime Field Received a Naive Datetime
2👍
TO ANY WINDOWS USERS:
I got the same error while creating my first django project. I couldn’t use sudo
on windows, so the command python manage.py runserver
only worked when I ran my terminal as administrator.
- Celerybeat not executing periodic tasks
- Group models in django admin
- Python-social-auth with Django: ImportError: No module named 'social_django'
- "The path python3 (from –python=python3) does not exist" error
1👍
For me, the issue was that I had two settings files; one for production and one for development. In my manage.py, I’d specified the deployment settings file and forgotten to add manage.py to my .gitignore, so when I ran the project locally it failed when trying to find the production database.
- How can I set a minimum password length when using the built-in Django auth module?
- Get only certain fields of related object in Django
- What is the different between the get logger functions from celery.utils.log and logging?
- Django update one field using ModelForm
1👍
If you are experiencing this problem on AWS EC2 node and using apache, to solve the problem I had to:
chown -R apache:apache project_folder
1👍
I have similar problem.
You just run command with sudo
sudo python3 manage.py runserver
Enjoy!
- Web Application (Django) typical project folder structure
- Does anyone know about workflow frameworks/libraries in Python?
- Django template rows of multiple items
- Django: Faking a field in the admin interface?
0👍
For many users(like myself), who might have this error while using another DB engine but have set the default engine via your env variable invocation as sqllite3
, you might want to either remove that default value or check that the env variable you’re checking is named the same way in your .env
file.
Rookie mistake but well,
- Separating Django App Views
- Django Gunicorn not load static files
- Annotating SUM aggregation function leading to 'None' value in Django
- Enable PK based filtering in Django Graphene Relay while retaining Global IDs
0👍
The issue in my case was to use double forward slash instead of triple forward slash:
I had to change:
os.environ.get("DATABASE_URL", f"sqlite://{BASE_DIR}/db.sqlite3")
To:
os.environ.get("DATABASE_URL", f"sqlite:///{BASE_DIR}/db.sqlite3")
- Django CMS malfunction: Site matching query does not exist
- Following users like twitter in Django, how would you do it?
0👍
You do not need sudo
for this. The solution is to create a ‘db’ folder in your project root directory before running the migrate command.
Apparently, ‘manage.py’ does not have permission to create folders on your machine, so create the folder and everything should work.
- Sending request.user object to ModelForm from class based generic view in Django
- Model Method from rest_framework modelSerializer
-1👍
@whinytween96 : I have seen this problem occur more when sudo
is used to run some commands and not for others. You need to be consistent with the usage of sudo
to fix this problem. I had the DB issue and I fixed it by running the command again with sudo
prefixed.
i.e.
sudo python manage.py runserver
sudo python manage.py makemigrations
sudo python manage.py migrate
fixed the problem for me.
- How to limit choices of ForeignKey choices for Django raw_id_field
- Django unique together constraint failure?
- Graphene-python performance issues for large data sets