Package: diafo
Diafo is a simple Django app for generating dynamic forms during the runtime.Detailed documentation is in the “docs” directory.RequirementsPython: 3.4, 3.5, 3.6Django: 1.11, 2.0bDjango bootstrap form: 1.4InstallationInstall using pip:pip3installdiafopip3installdjango-bootstrap-formThen add'django_filters'to yourINSTALLED_APPS.INSTALLED_APPS=[...'diafo','bootstrapform',]Include the polls URLconf in your project urls.py like this:url(r'^diafo/', include('diafo.urls')),Runpython manage.py migrateto create the diafo models.UsageDiafo can be used for generating questionnaires consisting various questions during runtime. One can specify the question type like CharField, TextFied, ChoiceField, MultipleChoiceField, etc. Requirement can also be mentioned whether the question is compulsary or not.Let see its usage through a simple survey webapp.fromdiafo.modelsimportQuestionnaireclassSurvey(models.Model):title=models.CharField(max_length=200)#link the form to your modelquestionnaire=models.OneToOneField(Questionnaire,null=True)And then in your view you could do:defnew_survey(request):...#get the title by using form or any how..questionnaire=Questionnaire.objects.create(name=tilte)survey=Survey.objects.create(title=title,questionnaire=questionnaire)returnHttpResponseRedirect(reverse('diafo:admin_view',kwargs={'pk':survey.form.pk}))So now that you have questionnaire linked to your model,you can add questions and edit the questionnaire thru the diafo:admin_view,
and let the user fill the questionnaire through diafo:user_view.The diafo main URLs are as follows:urlpatterns=[# for adding question,editing questionnaire detail,seeing responses,etcurl(r'^admin/(?P<pk>[0-9a-f-]+)/$',views.admin_view,name='admin_view'),# for normal users to fill the questionnaire(no edit rights)url(r'^user/view/(?P<view_id>[0-9a-f-]+)/$',views.user_view,name='user_view'),]The Questionnaire model is as follows:classQuestionnaire(models.Model):name=models.CharField(max_length=200,null=True)# id used for admin purpose.. used as pk in admin view#id and pk are same since primary key is Trueid=models.UUIDField(primary_key=True,default=uuid.uuid4,editable=False)# view_id - used for normal user (can only see and fill the questionnaire)view_id=models.CharField(max_length=50,unique=True,default=uuid.uuid4)#specific settings (can be edited thru diafo admin view for given questionnaire)requires_sign_in=models.BooleanField(default=False,blank=True)collect_identity=models.BooleanField(default=False,blank=True)This is how you can use use the diafo in your views or templates.classyourview(request,your_parameters):...# get the questionnare object.ifwant_to_go_on_admin_view:# use questionnare.pk and diafo:admin_view#for use in template href={% url 'diafo:admin_view' questionnaire.pk %}returnHttpResponseRedirect(reverse('diafo:admin_view',kwargs={'pk':questionnaire.pk}))elifwant_a_rendered_form_for_user:# use questionnaire.view_pk and diafo:user_view#for use in template href={% url 'diafo:user_view' questionnaire.view_id %}returnHttpResponseRedirect(reverse('diafo:admin_view',kwargs={'view_id':questionnaire.view_id}))SupportIf you have questions about usage or development you can contact me.BugsReally? Oh well… Please Report. Or better, fix :)