Create a queryable data source from an existing database.
Project description
Django Rest Framework Discovery
Discovery allows you to create an API from an existing database with little to no effort. This project is based on Shabda Raaj's Bookrest. You can then leverage the capabilties of the Django Rest Framework to apply filtering, pagination and documentation generation.
Requirements
For successful generation, you need to have a primary key present in the table. Otherwise, it will be silently ignored.
Installation
pip install djangorestframework-discovery
In your settings.py
:
INSTALLED_APPS = [
# ...
"rest_framework",
"rest_framework_discovery",
]
Add a variable to your settings.py
named DISCOVERY_PROFILE_NAME
. You can use any value, but discovery
is recommended. You will use that to define the database you would like to use for API generation.
DISCOVERY_PROFILE_NAME = 'discovery'
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(BASE_DIR, "db.sqlite3"),
},
DISCOVERY_PROFILE_NAME: {
'NAME': 'YOUR_DB_NAME',
'ENGINE': 'django.db.backends.postgresql',
'USER': 'YOUR_DB_USER',
'PASSWORD': 'YOUR_DB_PASSWORD',
'HOST': 'YOUR_DB_HOST',
'PORT': 'YOUR_DB_PORT',
},
}
Add the generated patterns to the rest of your application by modifying the urls.py
.
urlpatterns = [
# ...
url(r'^api/discovery/', include('rest_framework_discovery.urls')),
]
Configuration
You can configure the following in settings.py
:
DISCOVERY_PROFILE_NAME:
The database profile name to use with discovery.DISCOVERY_INCLUDE:
A list of tables that you would like to only include.DISCOVERY_EXCLUDE:
A list of tables that you would like to ignore.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for djangorestframework_discovery-0.1.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e1b191ca6a1cd530fe4faaa344dc27c4c43511db0540e007ba6fac24865c91d |
|
MD5 | 5a2a584685267b290653d7a33be03c54 |
|
BLAKE2b-256 | ffe5901db71566970950d8f915f5247521216f1d7f644e936bd3e0033bf87811 |