An easy to use project template in Django 1.11, focused on a custom backend for a mobile app.
As Intelligems has stopped operations since Aug19, this repository remains unmaintained. Whoever may be interested to keep it up-to-date or extend it, DM koslib to arrange project transfer.
This repo acts as a decent starting point for those who are looking for a custom backend deployment for their mobile app. It includes a full-serving django project which exposes a RESTful API, manages user instances and is highly configurable.
In fact, this project is not a package that you can include in your project and use right-away, but it's a project template that you can download, extend and keep working on it as a base for your new project.
3rd-party apps it includes:
django-storages
, to store files in AWS S3 (the most commonly used object storage)django-allauth
, for social media authenticationdjango-anymail[mailgun]
, to send transactional emails using Mailgun (first 10k messages/month are free)djangorestframework
, for the RESTful APIdjango-rest-swagger
, to automatically generate documentation for your RESTful API endpointsdjango-rest-auth
, to provide social media authentication over the APIdjango-filters
, which provides filtering capabilities in the DRF API viewsdjango-guardian
, for custom object or model level permissionscelery
, for background tasks handling. By default, it's expected to be used for device registration on the AWS SNS service.django-extensions
, offering a collection of custom extensions for Djangodjango-environ
, following the 12-factor methodology
- Python3
- Git
- pip
- virtualenv (recommended)
- Clone this repo on your local machine:
git clone https://github.com/intelligems/django-mobile-app
- We strongly advise to create a Python virtual environment and install the project requirements in there:
mkvirtualenv <env-name> --python=`which python3`
- Install project requirements inside your newly created local virtual environment:
pip install -r requirements.txt
- Inside the
settings
path, create an.env
file. Add in there all the environment variables that should be included in the project runtime. - It's time to perform your first database migrations - no worries, we have included them too:
python manage.py migrate
- Run the server!
python manage.py runserver 0.0.0.0:80
For the push_devices
app usage, you are expected to use the AbstractMobileDevice
abstract model.
You can extend it and add any fields you wish, but you are not allowed (by Django) to override the same fields that the AbstractMobileDevice
model uses.
In order to create a push device, inside the create view of your devices' API, import the sns registration method
from core.mobile_devices.tasks import register_device_on_sns
and use the delay
method to register the newly created device on SNS. This will assign the ARN endpoint on the device model, so that you will be able to publish push notifications to your registered push device.
For example:
device = Device.objects.create(**data)
register_device_on_sns.delay(device)