A document library that integrates with multiple data sources (like digiLocker, Google Drive, local storage etc.) and storage services (like S3 and Google Cloud Storage) and uploads data from these data sources to the chosen storage service. It can be integrated with any Django Project.
With multiple different software and accounts being used to store our documents and images, the files that are important to us are spread out across these. This creates a need to bring all these files into a storage service, making it easier to store, search and keep track of files in one place.
- Python
- Django: Django builds better web apps with less code
- DRF: A powerful and flexible toolkit for building Rest APIs with Django
- Frontend: HTML5, Bootstrap, JS
- Architecture of the Library
-
Local Storage
-
Digimocker (mock of Digilocker)
Install the package
pip install django-doclib
demo_proj
├── credentials_dir
| └── credentials_gcs.json
├── media
└── django_project_folder
├── settings.py
├── asgi.py
├── .env
├── wsgi.py
└── urls.py
-
Add
doclib
andrest_framework
to your INSTALLED_APPS setting like thisINSTALLED_APPS = [
...
'doclib',
'rest_framework',
] -
Include the doclib URLconf in your project urls.py like this
path('doclib/', include('doclib.urls'))
-
Provide
MEDIA_ROOT
in your project settings.py, something like thisMEDIA_ROOT = os.path.join(BASE_DIR, 'media')
-
For integrating with Google Drive
-
Make a directory with name
credentials_dir
at the project root level -
Put the google api client secret json file with name as
credentials_gcs.json
incredentials_dir
directory For getting the API and Developer keys, visit here. -
Make a
.env
file in the project folder directory (at the project settings.py level) and put the Browser API keys obtained from the Google API Console like this (don’t use quotations around strings)DEVELOPER_KEY
=##################
CLIENT_ID
=##################
APP_ID
=##################
-
-
For setting the environment variables, follow this
-
Add these below lines in the project
settings.py
import environ env = environ.Env() environ.Env.read_env()
-
For setting the above API Keys put these below lines in the
settings.py
DEVELOPER_KEY = env("DEVELOPER_KEY") CLIENT_ID = env("CLIENT_ID") APP_ID = env("APP_ID")
-
-
Run
python manage.py migrate
to create the doclib models. -
Start the development server by running
python manage.py runserver localhost:8000
-
Visit
http://localhost:8000/doclib/
to access the doclib.
Contains the source code of the library
A demo django project using
doclib
library
For using this django project
-
install the library package
-
Clone the repo
-
Change working directory to repo_folder
cd path/to/repo_folder
-
Go to
slicedoc
foldercd slicedoc
-
Put the google api client secret json file with name as
credentials_gcs.json
incredentials_dir
directory -
Set the Django Secret Key and Browser API keys obtained from the Google API Console in the
.env
file in project directory -
Run
python manage.py migrate
to create the doclib models. -
Start the development server by running
python manage.py runserver localhost:8000
-
Visit
http://localhost:8000/doclib/
to access the doclib.