Package: django-form-creator
Django Form CreatorA Django application that lets users create forms. This is achieved firstly setting up a form and form questions. The user is able to select the field type per question and thus create a form that supports various field types.SectionsDjango Form CreatorSectionsWhat's in the box?InstallationPIP install andsettings.pyRegistering URLsUsing out of the box templatesUsageCreating the formCompleting the formContributingContributing to the codeWhat's in the box?The package contains the following:Models to store forms, form questions and responses.Views to create, edit, delete and submit forms.Templates to render each of the views (can be overwritten with your own).Ability to manage forms via the admin panel.Endpoints to download questions and responses both directly via views and via the admin panel.InstallationPIP install andsettings.pyThe application can be installed by running the following command:pip install django-form-creatorOnce installed, add the following to yoursettings.pyfile:INSTALLED_APPS=[..."form_creator",...]Run migrations:pythonmanage.pymigrateRegistering URLsIn your rooturls.pyfile, add the following:fromdjango.urlsimportpath,includeurlpatterns=[...path('form-creator/',include('form_creator.urls')),](Note: you don't need to call the path "form-creator/", rename this to whatever you want.)This will add the following URLs to your rooturls.pyfile:URLDescriptionforms/Forms list viewforms/create/Form create viewforms/<int:pk>-<slug:slug>/Form detail viewforms/<int:pk>-<slug:slug>/edit/Form edit viewforms/<int:pk>-<slug:slug>/delete/Form delete viewforms/<int:pk>-<slug:slug>/questions/edit/Form questions edit viewforms/<int:pk>-<slug:slug>/response/Form for users to submit responsesforms/<int:pk>-<slug:slug>/export/questions/Export form questions as CSVforms/<int:pk>-<slug:slug>/export/responses/Export form responses as CSVIf you want to limit the available views, you can import each of the views directly. The views are located inform_creator.views. If you want more control over the views, you inherit from the views inform_creator.viewsand override the methods you want to change.This might be useful when overriding templates and defining permissions.Using out of the box templatesThe package comes with some templates to allows uses to manage and complete forms. If you wish to use these templates, you will need to downloaddjango-crispy-formsand update yoursettings.pyfile. Follow the instructions below:pip install django-crispy-formsIn yoursettings.py:INSTALLED_APPS=[..."crispy_forms","form_creator",...]CRISPY_TEMPLATE_PACK="bootstrap4"The included templates also make use of messages. Add the following to yoursettings.pyfile:fromdjango.contrib.messagesimportconstantsasmessagesMESSAGE_TAGS={messages.DEBUG:"alert-secondary",messages.INFO:"alert-info",messages.SUCCESS:"alert-success",messages.WARNING:"alert-warning",messages.ERROR:"alert-danger",}UsageOnce you have installed the application, it's time to create your first form.
You can either go to the admin panel or access theform_creator:form_listview to start creating your first form. The default requirement is that you are logged in as a staff member in order to create a form.In our example, we will create a sample form via the admin panel, and then complete it via the front end.Creating the formThe first time to do is give your form a title and a description.OwnerThe form will need to have an owner. This is to allow a person to have control of the form via theform_creator:form_detailandform_creator:form_editviews. This is useful if the owner of the form is not a staff user who can manage the form via the admin panel. If this is not applicable, you can set the owner to yourself.StatusThere are 3 statuses to pick form: draft, active and inactive.Setting the status to either draft or inactive would mean that users are not able to complete the form.Setting the status to active would allow users to complete the form only if the form is within the start and end date.Start and end datesThe form must have a start date and can have an end date. The start date is the date from which the form will become live. Users will only be able to complete the form from the start date if the from status is set to active.The end date is an optional configuration. If the value is set, it means that the form has no end date. Otherwise, the form will be live until the end date.EditorsThe editors section is allowed to assigns users who can edit the form details and questions. They are not however able to delete the form itself.Setting QuestionsThe next section is where you will be able to set the questions for your form. You are able to set question, any applicable choices and the field type.Completing the formUsers are able to navigate to the URL forforms_creator:form_responseto complete the form.The form generated will respect the form fields selected and any choices allowed.Once the form is completed, they are able to press submit to submit the form.ContributingIf you would like to help develop this application here are a couple of things you can do:Raise an issue/suggestion on theGitHub repository.Find an issue/suggestion on theGitHub repositorythat you would like to work on, fork the repository and start working on it! When you're ready, create a pull request on GitHub.Contributing to the codeFork the repository and clone it to your local machine.Create a new branch for your changes.Create a virtual environment and install the dependencies.python3-mvenvvenv
.venv/bin/activate
pipinstall-rrequirements.txtexamplecontains a Django project for development. Move into that directory:cd exampleRun migrations:python manage.py migrate. As we are using an sqlite3 database, there is no need to create a database yourself.Create yourself a superuser:python manage.py createsuperuser.Run the development server:python manage.py runserver.Write some code, don't forget to write tests.Run the formatter/linter to format and lint your code:makeformat
makelintRun tests - let's try to stick to 100% coverage.cd..
maketest-coverageUpdate the coverage on theREADME.mdfile:make update_readme_cov.Commit your changes, push them to your repository and merge into master.Create a pull request to merge into the remote repository.