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.py
handles the database classes./web/views.py
handles the user views./web/forms.py
handles the forms logic.
Dependencies:
django-crispy-forms
is used to build the forms explicitly.django-filter
is used to enable filtering on list views.django-model-utils
InheritanceManager()
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 thePerson
model. - 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 makemigrations
andpython manage.py migrate
- Add new form in
web/forms.py
, all the responses subclass thePerson
form. You overrideget_form_layout
to explicitly build your new form layout, see django-crispy-forms documentation. - Add the new form choice to
PersonSelectForm
. - In
web/views.py
add the new form choice toPersonSelectView
PersonCreateView
,PersonUpdateView
.