Skip to content
Django Bikesharing Backend
Python Dockerfile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Basic backend for a mobility sharing service. Used on CCCamp2019.


  • Python (≥3.7)
  • A database that supports GIS extensions, for example PostGIS.


Create a file .env in the cykel subdirectory, with the following contents:

# insert your own random string here
# set to 1 to enable DEBUG output, or 0 to disable
# configure your database in a format supported by
# it is recommended to use a DNS alias for localhost, instead of "localhost", for CORS reasons,localhost
# set the full URL to the frontend
# CORS origins to whitelist, i.e. the frontend URL (with scheme, without path)

Install the required packages using pip install -r requirements.txt. It is recommended to use a virtualenv with your choice of tool, e.g. pipenv, in which case you can run pipenv install (and pipenv shell or prefix pipenv run to run commands).

Then run migrate to create the database tables.

Database configuration for PostgreSQL/PostGIS

You need to enable the following extensions in the cykel database after installing PostGIS:

CREATE EXTENSION postgis_topology;

The DB migration will fail otherwise.

Running the local server

Run runserver.

Configuring authentication

For the administration interface you can run createsuperuser to create an user with administrative rights and access the interface at http://localhost:8080/admin.

Then, visit /admin/ and edit the URL of the first Website (/admin/sites/site/1/change/).

Configuring OAuth

Visit /admin/socialaccount/socialapp/add/ (Add Social Application).

For example, for GitHub select "Provider: GitHub", "Name: github", the Client-Id and Secret are shown in the OAuth application creation process at GitHub.

When you create an OAuth2-Application at a provider, you need to enter a callback URL. This URL is in the format https://<host>/auth/<name>/login/callback/.

Update bike location

For updating the current bike location we provide the /api/bike/updatelocation endpoint.

One project which can use this together with TheThingsNetwork is the cykel-ttn adapter. Read the readme in the repository on how to use it - for authentication you need to add a new api key at /admin/rest_framework_api_key/apikey/.

Alternative: using Docker Compose

docker-compose pull
docker-compose up -d --build

To run the commands that are shown above, prefix them with docker-compose exec cykel:

docker-compose exec cykel python migrate
docker-compose exec cykel python createsuperuser

To use other settings (like ALLOWED_HOSTS) from above, add them to the environment in docker-compose.yml.

Docker Compose runs cykel and voorwiel (one frontend implementation), so you can develop and test with a client right away.

You can’t perform that action at this time.