{ "info": { "author": "Bulkan Evcimen", "author_email": "bulkan@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "Natural Language :: English", "Programming Language :: Python", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7" ], "description": "![domande](https://raw.github.com/bulkan/django-domande/master/logo.png)\n\nLogo by [@aurorachiarello](http://github.com/aurorachiarello)\n\n[![Build Status](https://travis-ci.org/bulkan/django-domande.png?branch=master)](https://travis-ci.org/bulkan/django-domande)\n\n\nA plugable Django app to represent a generic questions on forms.\n\n\nDependencies\n============\n\nHere are the list of dependencies;\n\n* [django-crispy-forms](http://django-crispy-forms.readthedocs.org) - This is used to render form fields with Bootstrap classes\n* [django_polymorphic](https://github.com/chrisglass/django_polymorphic/) - Provides an easy way of doing model inheritence.\n* [South](http://south.readthedocs.org/en/latest/) - For model migration. Please use it :smile:\n\n\nInstallation\n===========\n\nFor stable PyPI version\n\n pip install django-domande\n\n\nTo get development version\n\n pip install git+git://github.com/bulkan/django-domande.git\n\n\nIn your ```settings.py``` file change ```INSTALLED_APPS``` and add;\n\n```python\nINSTALLED_APPS = [\n ...\n 'crispy-forms' # need to add this for it's template tags to load\n 'polymorphic', # provides admin templates\n 'domande'\n ...\n]\n```\n\n__Note__ I'm assuming you have South already installed if not add ```south``` to ```INSTALLED_APPS```\n\nGeneral\n-------\n\n```domande``` uses model inheritence to simplify relationships to a list of questions and it does this with\nthe help of ```django-polymorphic```. At the moment ```domande``` supports two types of questions that are\nrendered differently by their accompanying forms.\n\nA TextQuestion were the __answer__ is a text and a ChoiceQuestion were the __answer__ is chosen \nby a set of Choices. TextQuestion and ChoiceQuestion are subclasses of Question.\n\nExample Usage\n=============\n\nModels\n-----\n\nCreate a model with a ManyToManyField to domande.models.Question. For example a Questionnaire;\n\n\n```python\nfrom django.db import models\nfrom django.contrib.contenttypes import generic\n\nfrom domande.models import Question, Answer\n\nclass Questionnaire(models.Model):\n name = models.CharField(max_length=256)\n\n questions = models.ManyToManyField(Question)\n```\n\n\nOnce you add a ManyToManyField to ```domande.models.Question``` and register your model with the django admin\ninterface the questions field will be handled uniquely. As ```domande.models.Questions``` is the parent model\nwhen you create a new one the admin inteface will display an additional step of choosing the child model to create an\ninstance of.\n\n\nView\n----\n\nNow you need to render the list of Questions in a view;\n\n\n```python\ndef questionnaire_view(request):\n\n # for sake of example use .get\n questionnaire = Questionnaire.objects.get(id=1)\n\n forms = [q.get_form()(prefix=str(q.id),\n content_object=request.user,\n question=q, form_tag=False)\n for q in questionnaire.questions.all().get_real_instances()\n ]\n\n # form is a list of TextQuestionForm or ChoiceQuestionForm\n```\n\ndomande's forms accept a ```content_object``` that is used when it creates and saves an Answer.\ndomande doesn't know in advance what type of _user_ or _entry_ model you have so it uses\ndjango's builtin ```ContentType``` framework to solve this.\n\nIn the above example it uses ```request.user```.\n\n\nTemplate\n--------\n\nin the template render the forms like so;\n\n```html\n{% load crispy_forms_tags %}\n\n
\n {% for form in forms %}\n {% crispy form %}\n {% endfor %}\n
\n```\n\nto process the validity of the forms and save the Answers;\n\n```python\n\ndef save_view(request, questionnaire):\n # for sake of example use .get\n questionnaire = Questionnaire.objects.get(id=questionnaire)\n\n forms = [q.get_form()(request.POST or None,\n prefix=str(q.id),\n content_object=request.user,\n question=q, form_tag=False)\n for q in questionnaire.questions.all().get_real_instances()\n ]\n\n forms_are_valid = []\n\n for form in forms:\n forms_are_valid.append(valid)\n valid = form.is_valid()\n if valid:\n t = form.save()\n\n forms_are_valid = all(forms_are_valid)\n```\n\nEach question model in domande has an Answer model that relates to it. A ChoiceQuestion will use a\nChoiceAnswer and a TextQuestion will use a ChoiceAnswer.\n\n\nDevelopment\n===========\n\n* Fork this repo, create a virtualenv and clone your fork. Then install the requirements\n\n pip install -r requirements.txt\n\n* If you have changed the models then create a migration;\n\n django-admin.py schemamigration --settings=domande.settings --pythonpath=$PWD\n\n* Please make sure existing tests pass and feel free to add more tests as you see fit.\n\n django-admin.py test --settings='tests.test_settings' --pythonpath=$PWD\n\n* Submit Pull Request\n", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/bulkan/django-domande", "keywords": null, "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "django-domande", "package_url": "https://pypi.org/project/django-domande/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-domande/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/bulkan/django-domande" }, "release_url": "https://pypi.org/project/django-domande/0.1.4/", "requires_dist": null, "requires_python": null, "summary": "django app to represent generic questions on forms", "version": "0.1.4" }, "last_serial": 868986, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "14aa6a6150437ab342099762cdb71c8d", "sha256": "11a39cb4befe27215d18e45d380070af9ec040d372342a31075871aa8466c248" }, "downloads": -1, "filename": "django-domande-0.1.tar.gz", "has_sig": false, "md5_digest": "14aa6a6150437ab342099762cdb71c8d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11040, "upload_time": "2013-03-11T13:13:40", "url": "https://files.pythonhosted.org/packages/3d/eb/d95515933b0138af8367dc586dbf9f240c9dda652e40cd9ca11bb12ab654/django-domande-0.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "91984bac6ba8797a8543811216ddc6c4", "sha256": "ff125d971f4c8b4963639fac5877ed6bcf76af505675a1e43ec5d41f501ba2a8" }, "downloads": -1, "filename": "django-domande-0.1.2.tar.gz", "has_sig": false, "md5_digest": "91984bac6ba8797a8543811216ddc6c4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10965, "upload_time": "2013-07-21T13:29:57", "url": "https://files.pythonhosted.org/packages/14/c8/829950f12f509c06e23a6071c2301f9fc384dc5053e6db53ee2e7733db8c/django-domande-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "5ad7f7ef7ecd667ef77b3cc62d8b2b08", "sha256": "24f0bb3edbe8681188d4f13317311648d02d668dafa80dfd5afecd948adb2f95" }, "downloads": -1, "filename": "django-domande-0.1.3.tar.gz", "has_sig": false, "md5_digest": "5ad7f7ef7ecd667ef77b3cc62d8b2b08", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10361, "upload_time": "2013-09-14T13:52:41", "url": "https://files.pythonhosted.org/packages/cf/38/654f77c079874b066aa65652040c9ddcf6b1726212cfb6f58e7ce5afe9cd/django-domande-0.1.3.tar.gz" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "864e713e9944363e592b3cdc55f5aaf2", "sha256": "9a103b207f58f3a50e4cbafc0eab49273c55cc2bc279eb66a9e30473a397f0b2" }, "downloads": -1, "filename": "django-domande-0.1.4.tar.gz", "has_sig": false, "md5_digest": "864e713e9944363e592b3cdc55f5aaf2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10629, "upload_time": "2013-09-19T00:00:00", "url": "https://files.pythonhosted.org/packages/1a/11/96220fe12707008dda2cf3f5299483aa4953b6b2eea1a856e3723577ba4e/django-domande-0.1.4.tar.gz" } ], "dev": [ { "comment_text": "", "digests": { "md5": "751ef8ff3f96886d067709b4ccac26f7", "sha256": "0047be98e78fd54064565161964700b6b5f3fd11591d8a6c63fe167f8bd68aec" }, "downloads": -1, "filename": "django-domande-dev.tar.gz", "has_sig": false, "md5_digest": "751ef8ff3f96886d067709b4ccac26f7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3571, "upload_time": "2013-02-27T13:22:06", "url": "https://files.pythonhosted.org/packages/e3/89/6c6b44de037d0e68df5aafe12bb80e9f8b337631fca734d95a100935c6d7/django-domande-dev.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "864e713e9944363e592b3cdc55f5aaf2", "sha256": "9a103b207f58f3a50e4cbafc0eab49273c55cc2bc279eb66a9e30473a397f0b2" }, "downloads": -1, "filename": "django-domande-0.1.4.tar.gz", "has_sig": false, "md5_digest": "864e713e9944363e592b3cdc55f5aaf2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10629, "upload_time": "2013-09-19T00:00:00", "url": "https://files.pythonhosted.org/packages/1a/11/96220fe12707008dda2cf3f5299483aa4953b6b2eea1a856e3723577ba4e/django-domande-0.1.4.tar.gz" } ] }