Skip to main content

Wagtail Polls

This is a really simple polls app for Django and Wagtail. It has a REST interface for front-end applications (like React) or you can render it in templates.

Installation

Requirements:

  • Django 3.x
  • Wagtail 2.x
  • Django rest framework 3.x

Start by installing the package

pip install wagtail-polls

Next migrate the models

python manage.py migrate

Add the polls app to your settings

INSTALLED_APPS = [
    ...
    'polls'
]

Add the urls or endpoints to urls.py

from polls import endpoints as polls_endpoints

urlpatterns += path('polls/', include(poll_router))

-- and/or --


from polls import urls as polls_urls

urlpatterns += path('polls/', include(polls_urls)) # adjust the url path to fit needs

Creating a Poll

In wagtail navigate to "Snippets" and select "Polls"

You can then compelete the form and add choices as desired.

Viewing results

Results will be shown in the wagtail admin interface for each poll under the choices

API Reference

Get all Polls

  GET /polls/

Response

{
    "count": 1,
    "next": null,
    "previous": null,
    "results": [
        {
            "id": 1,
            "question": "Does this work?",
            "description": "Testing 1 2 3",
            "image": null,
            "choices": [
                {
                    "id": 2,
                    "sort_order": null,
                    "choice": "no",
                    "poll": 1
                },
                {
                    "id": 1,
                    "sort_order": null,
                    "choice": "yes",
                    "poll": 1
                }
            ]
        }
    ]
}

Get Poll

  GET /polls/${id}/
Parameter Type Description
id string Required. Id of Poll to fetch

Response

{
    "id": 1,
    "question": "Does this work?",
    "description": "Testing 1 2 3",
    "image": null,
    "choices": [
        {
            "id": 2,
            "sort_order": null,
            "choice": "no",
            "poll": 1
        },
        {
            "id": 1,
            "sort_order": null,
            "choice": "yes",
            "poll": 1
        }
    ]
}

Post Vote

  POST /polls/vote/
Parameter Type Description
poll int Required. Id of poll
choice int Required. Id of choice
user int optional. Id of user

Response - returns a list of results for the poll

{
    "results": [
        {
            "no": 2
        },
        {
            "yes": 2
        }
    ]
}

License

MIT

Release files for wagtail-rest-polls 0.0.2

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

Source distribution (sdist)

Source distribution for wagtail-rest-polls 0.0.2
File Size Uploaded
wagtail-rest-polls-0.0.2.tar.gz 7.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for wagtail-rest-polls 0.0.2
File Interpreter ABI Platform
wagtail_rest_polls-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 16.6 kB

Release files / wagtail-rest-polls-0.0.2.tar.gz

Download URL wagtail-rest-polls-0.0.2.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
4b7464a0e608dfa632a67ab9f617ee80ee2f49ac68722050f7d3dd9517b49d1a
BLAKE2b-256 checksum
How to use checksums
035c7aff03c2a757aa6fe22e599b21c7b1df389b51ad3bd2480c42c1542f4e81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.1

Release files / wagtail_rest_polls-0.0.2-py3-none-any.whl

Download URL wagtail_rest_polls-0.0.2-py3-none-any.whl
Size 8.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e180c4bde453bbb72c1b0c7c510770bfa92335dd6974967e2bceab6bcb340609
BLAKE2b-256 checksum
How to use checksums
3d34ec8584466507632e1d9c4fea3d6e7ff78d3dbd8556e808eb6fd82b38b22e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.1

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

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