{"id":17548982,"url":"https://github.com/cguardia/questions","last_synced_at":"2025-04-09T13:05:58.817Z","repository":{"id":37790931,"uuid":"294851703","full_name":"cguardia/questions","owner":"cguardia","description":"Questions is a form library for Python that uses the power of SurveyJS for the UI.","archived":false,"fork":false,"pushed_at":"2024-12-06T16:50:42.000Z","size":333,"stargazers_count":33,"open_issues_count":47,"forks_count":11,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-02T12:07:56.236Z","etag":null,"topics":["form-generator","forms","python","python3","web-development"],"latest_commit_sha":null,"homepage":"https://questions.readthedocs.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cguardia.png","metadata":{"files":{"readme":"README.rst","changelog":"HISTORY.rst","contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.rst","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-12T02:10:34.000Z","updated_at":"2025-03-28T23:33:44.000Z","dependencies_parsed_at":"2023-02-17T15:01:05.179Z","dependency_job_id":"a85b9355-ff5f-43b6-bb74-5404e5572d66","html_url":"https://github.com/cguardia/questions","commit_stats":{"total_commits":337,"total_committers":3,"mean_commits":"112.33333333333333","dds":"0.25816023738872407","last_synced_commit":"a0eb789da77e6f3be6319a673ad97002533880a2"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cguardia%2Fquestions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cguardia%2Fquestions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cguardia%2Fquestions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cguardia%2Fquestions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cguardia","download_url":"https://codeload.github.com/cguardia/questions/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248045231,"owners_count":21038553,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["form-generator","forms","python","python3","web-development"],"created_at":"2024-10-21T02:48:04.275Z","updated_at":"2025-04-09T13:05:58.796Z","avatar_url":"https://github.com/cguardia.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"=========\nQuestions\n=========\n\n\n.. image:: https://img.shields.io/pypi/v/questions.svg\n        :target: https://pypi.python.org/pypi/questions\n\n.. image:: https://github.com/cguardia/questions/workflows/continuous-integration/badge.svg\n        :target: https://github.com/cguardia/questions/actions?query=workflow%3Acontinuous-integration\n\n.. image:: https://readthedocs.org/projects/questions/badge/?version=latest\n        :target: https://questions.readthedocs.io/en/latest/?badge=latest\n        :alt: Documentation Status\n\n\n\n\nQuestions is a Python form library that uses the power of SurveyJS_ for the UI.\nThe philosophy behind Questions is that modern form rendering usually requires\nintegrating some complex Javascript widgets anyway, so why not skip the markup\ngeneration completely? \n\n.. image:: https://www.delaguardia.com.mx/questions.gif\n\nIn Questions, forms are defined in Python similarly to other form frameworks,\nbut everything on the front end is handled by SurveyJS. This provides a lot of\nbenefits:\n\n* Nice, integrated UI, with powerful Javascript widgets.\n* SurveyJS is compatible with Angular2, JQuery, KnockoutJS, React and VueJS.\n  Questions makes sure that you get the right files for each version.\n* More than 20 question types, from simple text inputs and dropdowns to\n  elaborate widgets like dynamic panels and checkbox matrices.\n* Multiple look and feel options (themes), including Bootstrap_ CSS support.\n* Full client side validation (plus server side checking, too).\n* Use simple text expressions in question declarations to control which\n  questions to show depending on the answers to previous ones.\n* Complex forms can be defined easily using class composition.\n* Easy multi-page forms, with no state-keeping headaches.\n* Create forms directly from JSON definitions using SurveyJS form creator.\n* Generate Python code from dynamic JSON import.\n* Minimal code for simple apps. If you just need a form or two, you are set.\n* Zero Javascript code option. If you can use a CDN, no need to install or\n  download any javascript.\n* Out of the box integration with popular third party widgets, like select2_\n  and ckeditor_.\n* Supports the creation of tests and quizzes, by defining \"correct\" answers to\n  the questions, and optionally setting a maximum time to finish.\n\n.. _SurveyJS: https://surveyjs.io\n.. _Bootstrap: https://getbootstrap.com\n.. _select2: https://select2.org/\n.. _ckeditor: https://ckeditor.com/ckeditor-4/\n\n\nHow the Code Looks\n------------------\n\nTo get a feel for how Questions works, nothing better than looking at a simple\nexample::\n\n    from questions import Form\n    from questions import TextQuestion\n    from questions import RadioGroupQuestion\n\n\n    class SimpleForm(Form):\n        name = TextQuestion()\n        email = TextQuestion(input_type=\"email\", required=\"True\")\n        favorite_number = TextQuestion(title=\"What is your favorite number?\",\n            input_type=\"number\")\n        language = RadioGroupQuestion(title=\"Favorite Language\",\n            choices=[\"Python\", \"Other\"])\n        version = RadioGroupQuestion(title=\"Preferred Python Version\",\n            choices=[\"Python 2\", \"Python 3\"],\n            visible_if=\"{language} = 'Python'\")\n\nThis is a fairly conventional way to define forms, so no surprises here, but\nlook at the way the ``input_type`` parameter allows us to use different HTML5\ntext input methods. Pay special attention to the last line, where we use the\n``visible_if`` parameter to only show the Python version question if the\nanswer to the ``language`` question is \"Python\". Defining \"live\" form behavior\nin this way is something that is usually out of scope for server side code,\nbut Questions' SurveyJS integration allows us to do it.\n\n\nFull Working Multi-page Flask Application\n-----------------------------------------\n\nLet's show how easy things can be if your applications needs are simple. The\nfollowing is a complete application using the popular Flask_ web framework::\n\n    from flask import Flask\n    from flask import redirect\n    from flask import request\n\n    from questions import Form\n    from questions import FormPage\n    from questions import TextQuestion\n    from questions import DropdownQuestion\n\n\n    class PageOne(Form):\n        name = TextQuestion()\n        email = TextQuestion(input_type=\"email\", required=\"True\")\n\n\n    class PageTwo(Form):\n        country = DropdownQuestion(choices_by_url={\"value_name\": \"name\",\n            \"url\": \"https://restcountries.eu/rest/v2/all\"})\n        birthdate = TextQuestion(input_type=\"date\")\n\n\n    class Profile(Form):\n        page_one = FormPage(PageOne, title=\"Identification Information\")\n        page_two = FormPage(PageTwo, title=\"Additional Information\")\n\n\n    app = Flask(__name__)\n\n    @app.route(\"/\", methods=(\"GET\",))\n    def form():\n        form = Profile()\n        return form.render_html()\n\n    @app.route(\"/\", methods=(\"POST\",))\n    def post():\n        form_data = request.get_json()\n        # Here, we would save to a database or something\n        print(form_data)\n        return redirect(\"/thanks\")\n\n    @app.route(\"/thanks\")\n    def thanks():\n        return \"Thanks for your information\"\n\n    if __name__ == \"__main__\":\n        app.run()\n\nBy default, Questions uses a CDN for fetching the Javascript resources, which\nis why all that is needed to run the above code is installing Flask and\nQuestions. Of course, it is possible to install all the dependencies yourself\nand configure Questions to use your installation, but sometimes this is all\nthat's required to get a full working application.\n\nAdmittedly, our application doesn't do much, but we get a working form that you\ncan fill and submit in your browser. See how easy it is to get a multi-page\nform with navigation buttons. Also, notice how ``get_json`` is the only Flask\nrequest call we need to get the form data. \n\nAs the code shows, defining a multiple page form is very simple, and allows us\nto keep the form pages logically separated, and even using them independently\nor in combination with other forms with little additional work.\n\nFinally, take a look at the ``choices_by_url`` parameter in the\nDropdownQuestion, which allows us to get the dropdown choices from separate,\nrestful web services.\n\n.. _Flask: https://flask.palletsprojects.com/\n\n\nLicense and Documentation\n-------------------------\n\n* Free software: MIT license\n* Documentation: https://questions.readthedocs.io.\n\n\nCredits\n-------\n\nThis package was created with Cookiecutter_ and the\n`audreyr/cookiecutter-pypackage`_ project template.\n\n.. _Cookiecutter: https://github.com/audreyr/cookiecutter\n.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcguardia%2Fquestions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcguardia%2Fquestions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcguardia%2Fquestions/lists"}