osmcha-django

February 20, 2026 ยท View on GitHub

This is the Django backend API for osmcha.org, a tool for reviewing and analyzing edits to OpenStreetMap.

The frontend code is in a separate repository, osmcha-frontend. Bug reports and feature requests should be filed there by default, unless you're certain that your bug/request is specific to the backend.

License: BSD 2-Clause

OSMCha is an OpenStreetMap US project. You can support the project by making a donation.

Settings

osmcha-django relies extensively on environment settings which will not work with Apache/mod_wsgi setups. It has been deployed successfully with both Gunicorn/Nginx and uWSGI/Nginx.

For configuration purposes, the following table maps the 'osmcha-django' environment variables to their Django settings:

Environment VariableDjango SettingDevelopment DefaultProduction Default
DJANGO_CACHESCACHES (default)locmemredis
DJANGO_DEBUGDEBUGTrueFalse
DJANGO_SECRET_KEYSECRET_KEYCHANGEME!!!raises error
DJANGO_SECURE_BROWSER_XSS_FILTERSECURE_BROWSER_XSS_FILTERn/aTrue
DJANGO_SECURE_SSL_REDIRECTSECURE_SSL_REDIRECTn/aTrue
DJANGO_SECURE_CONTENT_TYPE_NOSNIFFSECURE_CONTENT_TYPE_NOSNIFFn/aTrue
DJANGO_SECURE_FRAME_DENYSECURE_FRAME_DENYn/aTrue
DJANGO_SECURE_HSTS_INCLUDE_SUBDOMAINSHSTS_INCLUDE_SUBDOMAINSn/aTrue
DJANGO_SESSION_COOKIE_HTTPONLYSESSION_COOKIE_HTTPONLYn/aTrue
DJANGO_SESSION_COOKIE_SECURESESSION_COOKIE_SECUREn/aFalse
DJANGO_DEFAULT_FROM_EMAILDEFAULT_FROM_EMAILn/a"osmcha-django <noreply@example.com>"
DJANGO_SERVER_EMAILSERVER_EMAILn/a"osmcha-django <noreply@example.com>"
DJANGO_EMAIL_SUBJECT_PREFIXEMAIL_SUBJECT_PREFIXn/a"[osmcha-django] "
DJANGO_CHANGESETS_FILTERCHANGESETS_FILTERNoneNone
PGUSERDATABASESNoneNone
PGPASSWORDDATABASESNoneNone
PGHOSTDATABASESlocalhostlocalhost
OAUTH2_OSM_KEYSOCIAL_AUTH_OPENSTREETMAP_KEYNoneNone
OAUTH2_OSM_SECRETSOCIAL_AUTH_OPENSTREETMAP_SECRETNoneNone
DJANGO_ANON_USER_THROTTLE_RATEANON_USER_THROTTLE_RATENone30/min
DJANGO_COMMON_USER_THROTTLE_RATECOMMON_USER_THROTTLE_RATENone180/min
DJANGO_NON_STAFF_USER_THROTTLE_RATENON_STAFF_USER_THROTTLE_RATE3/min3/min
OAUTH_REDIRECT_URIOAUTH_REDIRECT_URIhttp://localhost:8000/oauth-landing.htmlhttp://localhost:8000/oauth-landing.html
DJANGO_ENABLE_CHANGESET_COMMENTSENABLE_POST_CHANGESET_COMMENTSFalseFalse
DJANGO_OSM_COMMENTS_API_KEYOSM_COMMENTS_API_KEY''''

You can set each of these variables with:

$ export VAR=VALUE

During the development, you can define the values inside your virtualenv bin/activate file.

Filtering Changesets

You can filter the changesets that will be imported by defining the variable CHANGESETS_FILTER with the path to a GeoJSON file containing a polygon with the geographical area you want to filter.

Getting up and running

Basics

The steps below will get you up and running with a local development environment. We assume you have the following installed:

  • pip
  • virtualenv
  • PostgreSQL

Before installing the python libraries, we need to install some packages in the operational system:

$ sudo ./install_os_dependencies.sh install

For the next step, make sure to create and activate a virtualenv, then open a terminal at the project root and install the requirements for local development:

$ pip install -r requirements/local.txt

Create a local PostgreSQL database:

$ createdb osmcha

Run migrate on your new database:

$ python manage.py migrate

You can now run the runserver_plus command:

$ python manage.py runserver_plus

Open up your browser to http://127.0.0.1:8000/ to see the site running locally.

Setting Up Your Users

To create a normal user account, just go to Sign Up and fill out the form. Once you submit it, you'll see a "Verify Your E-mail Address" page. Go to your console to see a simulated email verification message. Copy the link into your browser. Now the user's email should be verified and ready to go.

To create a superuser account, use this command:

$ python manage.py createsuperuser

For convenience, you can keep your normal user logged in on Chrome and your superuser logged in on Firefox (or similar), so that you can see how the site behaves for both kinds of users.

How to login using the OAuth api

  • Make a POST request to <your_base_url>/api/v1/social-auth/ to receive the oauth_token, oauth_token_secret keys.
  • Take the oauth_token and redirect the user to https://www.openstreetmap.org/oauth/authorize?oauth_token=<oauth_token>.
  • You'll be redirected to the URL that you configured in your OSM OAuth key settings. That redirect url will contain the oauth_verifier param.
  • Make another POST request to <your_base_url>/api/v1/social-auth/ and send the oauth_token, oauth_token_secret and oauth_verifier as the data. You'll receive a token that you can use to make authenticated requests.
  • The token key should be included in the Authorization HTTP header. The key should be prefixed by the string literal "Token", with whitespace separating the two strings. For example: Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b.

Frontend

osmcha-frontend is a web interface that you can use to interact with the API. The web interface can be deployed separately and configured to talk to this Django app when making API requests. See the README in that repository for more details.

Feature creation endpoint

The feature creation endpoint allows only admin users to create features. You can use the admin site to create a token for a user.

Instances

The main instance is https://osmcha.org/. You can check the API documentation at https://osmcha.org/api-docs/.

There is currently no official staging instance.

Deployment

Check the Deploy file for instructions on how to deploy with Heroku and Dokku.

Get in contact

If you use, deploy or are interested in helping develop OSMCha, subscribe to our mailing list. You can report errors or request new features in the osmcha-frontend repository.