Skip to main content

django-questionnaire-core

A django application which can be used as a base / starting point for questionnaire functionality in your project. It heavily relies on django form fields & widgets and uses JSON fields to store the results.

Requirements

Quick start

  1. Add "questionnaire_core" and its dependency to your INSTALLED_APPS setting like this:

    INSTALLED_APPS = [
        ...
        'ordered_model',
        'questionnaire_core',
    ]
    
  2. Create a view based on questionnaire_core.views.generic.QuestionnaireFormView; a simple version might look like this:

    from django.http import HttpResponseRedirect
    from django.urls import reverse
    from django.utils.http import urlencode
    
    from questionnaire_core.models import Questionnaire, QuestionnaireResult
    from questionnaire_core.views.generic import QuestionnaireFormView
    
    class BasicQuestionnaireView(QuestionnaireFormView):
        template_name = 'basic_questionnaire.html'
    
        def get_questionnaire(self):
            return Questionnaire.objects.get(pk=self.kwargs.get('pk'))
    
        def get_questionnaire_result_set(self):
            if self.request.GET.get('result_set'):
                return QuestionnaireResult.objects.get(pk=self.request.GET.get('result_set'))
            return QuestionnaireResult(questionnaire=self.get_questionnaire())
    
        def get_success_url(self):
            return reverse('basic_questionnaire', args=(self.kwargs.get('pk'),))
    
        def form_valid(self, form):
            # Add current result set to the url (allows editing of the result)
            redirect = super().form_valid(form)
            url_params = urlencode({'result_set': form.current_result_set.pk})
            return HttpResponseRedirect('{url}?{params}'.format(url=redirect.url, params=url_params))
    
  3. Add the new view to your URLconf:

    path('questionnaire/<int:pk>/', BasicQuestionnaireView.as_view(), name='basic_questionnaire'),
    
  4. Run python manage.py migrate to create the questionnaire_core models.

  5. Start the development server and visit http://127.0.0.1:8000/admin/ to create a questionnaire (you'll need the Admin app enabled).

  6. Visit http://127.0.0.1:8000/questionnaire/1/ to test your first questionnaire.

Development setup

  1. Upgrade packaging tools:

    python -m pip install --upgrade pip
    python -m pip install --upgrade setuptools wheel
    
  2. Install Django (the example_app expects django 3.2):

    python -m pip install Django~=3.2.0 django-ordered-model psycopg2
    
  3. Install tox, isort & flake8

    python -m pip install tox isort flake8
    

Metadata

Release files for django-questionnaire-core 1.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-questionnaire-core 1.4.0
File Size Uploaded Provenance Actions
django-questionnaire-core-1.4.0.tar.gz 14.8 kB Without provenance Details for django-questionnaire-core-1.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-questionnaire-core 1.4.0
File Interpreter ABI Platform Actions
django_questionnaire_core-1.4.0-py3-none-any.whl Python 3 none any Details for django_questionnaire_core-1.4.0-py3-none-any.whl

Total release size: 36.9 kB

Release files / django-questionnaire-core-1.4.0.tar.gz

Download URL django-questionnaire-core-1.4.0.tar.gz
Size 14.8 kB
Tags Source
SHA-256 checksum
How to use checksums
dec082f784c713663255ee50508302e3433f5f78bfa4441080432f21ba012393
BLAKE2b-256 checksum
How to use checksums
b0da384183f9f0da9945219b840fe6673a0c49bb63523229d080659a21ff9d86
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release files / django_questionnaire_core-1.4.0-py3-none-any.whl

Download URL django_questionnaire_core-1.4.0-py3-none-any.whl
Size 22.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
532379c42b2287b14add1dbcde528327d7778b13646ff0b8102af8b2b8afaf10
BLAKE2b-256 checksum
How to use checksums
3b36a281c9c1c98bebebf761c5978421835e5d47d13f0083297a550d48400610
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Security for django-questionnaire-core 1.4.0

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page