A slightly opinionated starting point for creating JSON API using Django, Django Rest Framework, PostgreSQL.
Note: Python 2 is not supported.
/api/token/
/api/token/verify/
/api/token/refresh/
/api/users/
/api/users/{id}/
/api/things/
/api/things/{id}/
All primary keys are 64 bit integers generated by simpleflake. API serves primary keys as strings to work around possible client constraints, for instance, JavaScript's Number.MAX_SAFE_INTEGER
Checkout the source code for,
helpers.models.BaseModel
implements simpleflake primary keys for models, in addition to providing some common fields.helpers.serializers.BaseModelSerializer
implements conversion of simpleflake primary keys to strings.
django-filter filter backend is integerated.
12 factor settings, read from environment variables
See django12factor for more details.
Making settings available as environment variables is not, and should not be, a part of the API application itself. I use direnv during local development, you may use a differnt way to supply configuration.
I am using pipenv to create/manage virtualenvs. Install it, read the docs before proceeding.
Once pipenv is installed,
git clone https://github.com/mnazim/django-rest-kickstart.git myproject
cd myproject
rm -rf .git
pipenv --three
pipenv install -d
pipenv shell
Provide following settings via environment variables.
DEBUG
SECRET_KEY
ALLOWED_HOSTS
DATABASE_URL
as expected by dj-database-url
and the rest is just Django,
./manage.py migrate
./manage.py createsuperuser
./manage.py runserver
Happy hacking!