A survey application for Nottinghamshire Healthcare NHS Foundation Trust.
Python 3.10^ is required.
Install Poetry.
Your .env file (or environment variables) should contain:
SECRET_KEY=generatedkey
- In root directory, run
poetry install - Enter virtual env, run
poetry shell - Change directory to
/quenten/ - Run database migrations
python manage.py migrate - Add a new user
python manage.py createsuperuser - Seed initial form values
python manage.py loaddata seed_data.json --app web - Run application
python manage.py runserver - Open
http://localhost:8000/
It is a straightforward Django application, allowing users to enter survey data and "code" their responses accordingly.
The application is in the web directory.
/web/models.pyhandles the database classes./web/views.pyhandles the user views./web/forms.pyhandles the forms logic.
Dependencies:
django-crispy-formsis used to build the forms explicitly.django-filteris used to enable filtering on list views.django-model-utilsInheritanceManager()is used to manage the object queries, allowing access to object subclasses.
The initial question responses are seeded into the database through /web/fixtures/seed_data.json. You can then amend these values in the Django admin.
The application is built around the initial five forms, adding new forms should replicate this logic.
- Add a new model in
web/models.py, all the responses subclass thePersonmodel. - Add any further fields to this model, or add the existing mixins as necessary (for example, the
DemographicsMixin) - Make database migrations in
/quenten/:python manage.py makemigrationsandpython manage.py migrate - Add new form in
web/forms.py, all the responses subclass thePersonform. You overrideget_form_layoutto explicitly build your new form layout, see django-crispy-forms documentation. - Add the new form choice to
PersonSelectForm. - In
web/views.pyadd the new form choice toPersonSelectViewPersonCreateView,PersonUpdateView.