django-odk
Django data collection tool using ODK-collect mobile app.
Prerequisite
- Django web site up and running
- Smartphone or tablet with ODK-Collect installed
- XLSForm file with 3 tabs 'survey', 'choices', 'settings'
NEW from version 1.0.2 (xls2xml & create final model)
- Since most of Xforms are using
geopoint, the database must be set up with vector geodatabase functionality: PostGIS, Oracle Spatial, SQLite/SpatiaLite - Java Runtime Environment (JRE) installed
$ sudo apt install default-jrefor XForm validation used by xlsconv
Installation
- Run
$ pip install django-odk
$ python manage.py migrate
$ python manage.py createsuperuser
- Add odk and odkdata to your INSTALLED_APPS settings
INSTALLED_APPS = (
...
'odk',
'odkdata',
)
- Add LOCALE_PATHS and appropriate language_code in settings
LOCALE_PATHS = [os.path.join(BASE_DIR, 'odk', 'locale')]
LANGUAGE_CODE = 'en'
# translated LANGUAGE_CODE: fr
- Add appropriate AUTH_USER_MODEL in settings.py
AUTH_USER_MODEL = 'auth.user'
- (Recommended) Require authentication for ODK Collect submissions (
/odk/submission). Credentials are those of a Django user, entered in ODK Collect under Settings > Project settings > Server > Username / Password. Serve the site over HTTPS: Basic auth sends the password in clear text.
ODK_SUBMISSION_AUTH = True
-
For a more interactive app, configure logging as explained in Lincoln Loop and messages as explained in Django
-
For logging, add
odkandodkdataentry tologgerskey of your logging file and adapthandlersaccording to yours.
'loggers': {
...
'odk': {
'handlers': ['console', 'debugger', 'warning', 'error'],
'level': 'DEBUG' if DEBUG else 'INFO',
'propagate': False,
},
'odkdata': {
'handlers': ['console', 'debugger', 'warning', 'error'],
'level': 'DEBUG' if DEBUG else 'INFO',
'propagate': False,
},
}
- Add is_odk_admin and is_odk_user property to your AUTH_USER_MODEL (django.contrib.auth.models file or specific accounts.models)
@property
def is_odk_admin(self):
return self.groups.filter(name='odk-admin').exists()
@property
def is_odk_user(self):
return self.groups.filter(name='odk-user').exists()
- Add odk.urls to the main urls.py file:
urlpatterns = [
...
path('odk/', include('odk.urls'), name='odk'),
]
- Add menu or buttons to access Available form
# bootstrap5 menu item example
<li><a class="dropdown-item" href="{% url 'odk:xform_list' %}">{% trans "ODK available forms" %}</a></li>
- Add menu or buttons to access Submitted form
# bootstrap5 menu item example
<li><a class="dropdown-item" href="{% url 'odk:xformsubmit_list' %}">{% trans "ODK submitted forms" %}</a></li>
Connect to the Django admin site
- create a group 'odk-admin' with create, read, update access on odk objects
- Associate this group to the appropriate users
Available form: Build, Upload, Convert, Create
Connect to django-odk => Available form => Add and follow 4 steps:
-
Build an XLSForm file with 3 tabs 'survey', 'choices', 'settings' Cfr documentation. Do not forget to add 'today' & 'username' fields in Survey tab!
-
Upload xlsx file (XForm) by clicking on 'Choose file' and Save
-
Convert xlsx file to xml XForm compatible file Thanks pyxform! If it is not working in production (504 Geteway timeout), xml (previously created from XLSForm Online) can be uploaded manually from admin site.
From this point, you are ready to go with form encoding on your smartphone!
Follow ODK instructions to configure the connexion to the server
Get, fill-in and submit data using ODK Collect
- Create Model in odkdata to get submitted data in a model formatted like xlsx form. Thanks xlsconv!! Model creation is done into App
odkdatawith table name followed by_origsuffix when converted by xlsconv.
Submitted form
Go to Submitted form menu of your server to see submitted data in XML format. On record view, click on Insert button to insert submitted XML data into odkdata.models created on step 4 hereabove.
Several record insert is available through admin interface. Select appropriate records (ie: those without insert date) and choose Insert in odkdata model from action dropdown list and click on 'Send' button.
What next?
Create a new app in you project like odkdata2 with templates, views (importing odkdata.models info) and urls to manage display/map/export-xls/update/analyse submitted data from ODK-Collect!
- Do not forget to add
odkdata2logger specifications in settings.py
Comments/Improvements welcome!
Investigate WQ Framework but I still don't see how to deploy offline forms on smartphone.
Metadata
Release files for django-odk 1.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django_odk-1.2.1.tar.gz | 56.6 kB | Without provenance | Details for django_odk-1.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_odk-1.2.1-py3-none-any.whl | Python 3 | none | any | Details for django_odk-1.2.1-py3-none-any.whl |
Total release size: 124.3 kB
Release files / django_odk-1.2.1.tar.gz
| Download URL | django_odk-1.2.1.tar.gz |
|---|---|
| Size | 56.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
feeed5b99919fe5ad31a56e09f8f79c7aa990622e681efda6bf102c0268d1dfc
|
|
BLAKE2b-256 checksum How to use checksums |
15f3d0d3a36e82aad63d6affd1c04619b1014622c73f43bb3d3e260509b48377
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.21 {"installer":{"name":"uv","version":"0.12.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / django_odk-1.2.1-py3-none-any.whl
| Download URL | django_odk-1.2.1-py3-none-any.whl |
|---|---|
| Size | 67.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
24448562bfbeb1e657ab2d9b3a0603d0251a6b8846fdd8c7cf6df2778454b613
|
|
BLAKE2b-256 checksum How to use checksums |
cf09b2add5af65e50ae9fb6af65d0f195785f14d8c2355d727028c766adccb83
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.21 {"installer":{"name":"uv","version":"0.12.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for django-odk 1.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.