Showing posts with label Django. Show all posts
Showing posts with label Django. Show all posts

Sunday, April 21, 2019

Django Sqlite3 database with write access

To use the Sqlite3 database with write permissions, the following setup is needed.
#1. First create a directory say 'db' under the Project folder.
#2. Change the settings.py to include the database section as following:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR,'db/db.sqlite3'),
}
}
#3. Run the python3 manage.py migrate to create the db.sqlite3 file under db directory.
#4. Change the group permissions of the folder db:
 sudo chgrp -R www-data db
#5. Change the access permissions of the folder db:
sudo chown -R 774 db 
6. In the apache site config, include the following to give access to db directory:
 <Directory /Path_To_Project/db>
        Require all granted
    </Directory>

Apache and Django running FireStore Database

To run Apache with Django needs the following setup to access FireStore Database:
In the site config file, it needs the following directive:

WSGIApplicationGroup %{GLOBAL}

All WSGI applications in this group will execute within the context of the same Python sub interpreter of the process handling the request. This is necessary to access the FireStore Database with the same Credentials.