Package: django-form-generator
Django Form Generatordjango form generator will help you create forms very easily.
you can use it any where in your html files.there is an API-manager tool for you to call some APIs on loading form or after submit.Installationinstall it via pip:pipinstalldjango-form-generatoradd ('django_form_generator','django_htmx','crispy_forms','crispy_bootstrap5','captcha','tempus_dominus', 'rest_framework', 'drf_recaptcha') to yourINSTALLED_APPS:INSTALLED_APPS=[...'django_htmx','crispy_forms','crispy_bootstrap5','captcha','tempus_dominus','rest_framework','drf_recaptcha','django_form_generator',]do amigrate:pythonmanage.pymigratedo acollectstatic:pythonmanage.pycollectstaticfinally include django_form_generator urls to yoururls.pyfromdjango.contribimportadminfromdjango.urlsimportpath,includeurlpatterns=[path('admin/',admin.site.urls),...path('form-generator/',include(('django_form_generator.urls','django_form_generator'),namespace='django_form_generator')),...]RequirementsPython >= 3.10Django >= 4.0Form Usageregular html usage:<!doctype html><htmllang="en"><head>...</head><body>{% load django_form_generator %}

    {% render_form 1 %} {# it will render the form that has id of 1 #}</body></html>RichText fields:To use this tags on a Richtext field likeCKeditorortinymce.Note: In some richtext packages some elements (specialy jinja elements) will be removed from the field
there are some tweaks to solve this problems on the packages documentations.Admin panel:CK-Editor example./app_name/templates/index.html<!doctype html><htmllang="en"><head>...</head><body>{% load django_form_generator %}

    {{ object.rich_text_field|eval_data }}</body></html>API manager UsageThere is also an API manager for the formsAdmin panel:example:Note:first_name,last_nameandjobare the name of the fields that are defined in a form which this api is assigned to.Note: assigend apis will be called automatically.
the ones with execution_time ofPREwill be called when form renders.
and the ones with execution_time ofPOSTwill be called after form submition.Note: in the response field you can write HTML tags
it will be rendrend assafe.Note: You have access torequestglobaly in api managerAlso you have access to the response of the api. so you can useJinjasyntax to access data.
You can use this feature on the (url,body,response) fields ofAPIManagermodelCreating APIexample:Note: To show the response use the template tag of{% render_pre_api form_id api_id %}inside your html file that theformis there.Responseexample:output of the api:{"result":[{"first_name":"john","last_name":"doe","avatar":"https://www.example.com/img/john-doe.png",},{"first_name":"mary","last_name":"doe","avatar":"https://www.example.com/img/mary-doe.png",}]}in the response field you can do:<h1>Response of the API:</h1>{% for item in result %}<p>{{item.first_name}}</p><p>{{item.last_name}}</p><imgsrc="{{item.avatar}}">{% endfor %}html usage:<!doctype html><htmllang="en"><head>...</head><body>{% load django_form_generator %}

    {% render_pre_api 1 %} {# it will render all pre apis that are assigned to a form with id of 1 #}

    {% render_pre_api 1 6 %} {# it will render the pre api with id of 6 which is assigned to a form with id of 1 #}


    {% render_post_api 1 %} {# it will render all pre apis that are assigned to a form with id of 1 #}

    {% render_post_api 1 7 %} {# it will render the post api with id of 7 which is assigned to a form with id of 1 #}</body></html>ExtraAPI Manager:you can access the whole submited data by adding{{ form_data }}to your apibody.Form Style:to have multiple styles the html oftemplate_name_p(attribute of django.forms.Form) will be replace by our html file. ({{form.as_p}})there are 3 styles(or actualy styel of rendering fields) for the forms:In-line Style[^1].In-order Style[^2].Dynamic Style[^3].[^1]: In every line two fields will be rendered.[^2]: In every line one field will be rendered.[^3]: this style will render fields respect to the field position (inline,inorder,break)Note: If you want to render two fieldsinlineand one fieldinorderyou should usebreakfor the second fieldexample:field1 inlinefield2 breakfield3 inorderNote: You can add your custom styles by create new TextChoices object and add it tosettings.pyexample:myapp/const.pyfromdjango.db.modelsimportTextChoicesclassCustomFormGeneratorStyle(TextChoices):MY_STYLE="myapp/templates/my_style.html",'My Custom Style'...myproject/settings.pyDJANGO_FORM_GENERATOR={"FORM_STYLE_CHOICES":"myapp.const.CustomFormGeneratorStyle"}URLS:# to access the form you can call this url:"""GET: http://127.0.0.1:8000/form-generator/form/1/"""#orreverse('django_form_generator:form_detail',kwargs={'pk':1})#api:reverse('django_form_generator:api_form_detail',kwargs={'pk':1})# to access the response of the form you can call this url the kwarg_lookup is UUID field"""GET: http://127.0.0.1:8000/form-generator/form-response/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/"""#orreverse('django_form_generator:form_response',kwargs={'unique_id':'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'})#api:reverse('django_form_generator:api_form_response',kwargs={'unique_id':'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'})Settings:below is the default settings for django_form_generator. you can change them by adding it to yoursettings.pyDJANGO_FORM_GENERATOR={'FORM_RESPONSE_SAVE':'django_form_generator.models.save_form_response','FORM_EVALUATIONS':{'form_data':'{{form_data}}'},'FORM_GENERATOR_FORM':'django_form_generator.forms.FormGeneratorForm','FORM_RESPONSE_FORM':'django_form_generator.forms.FormGeneratorResponseForm','FORM_STYLE_CHOICES':'django_form_generator.const.FormStyle','FORM_MANAGER':'django_form_generator.managers.FormManager','FORM_GENERATOR_SERIALIZER':'django_form_generator.api.serializers.FormGeneratorSerializer','FORM_RESPONSE_SERIALIZER':'django_form_generator.api.serializers.FormGeneratorResponseSerializer',}AttentionTo have nice styled fields you can add crispy-form to yoursettings.pyCRISPY_ALLOWED_TEMPLATE_PACKS='bootstrap5'CRISPY_TEMPLATE_PACK='bootstrap5'To access google recaptcha you should add these to yoursettings.pyNote: you can have public & private keys by registring your domain onGoogle recaptcha admin consoleRECAPTCHA_PUBLIC_KEY='public_key'RECAPTCHA_PRIVATE_KEY='private_key'# ===== FOR DRF =========DRF_RECAPTCHA_SECRET_KEY="YOUR SECRET KEY"Note: If you don't want to use google-recaptcha(django-recaptcah)
you should add below code to yoursettings.pySILENCED_SYSTEM_CHECKS=['captcha.recaptcha_test_key_error']Dependency PackagesHTMXCRISPY-FORMS (crispy-bootstrap5)REQUESTSDJANGO-RECAPTCHADJANGO-TEMPUS-DOMINUSDJANGO-REST-FRAMEWORKLicenseMIT