
Security News
Open Source CAI Framework Handles Pen Testing Tasks up to 3,600× Faster Than Humans
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
A Django reusable App for dynamically designing and generating forms.
Install the package using pip:
pip install django-dynforms
Add dynforms
and it's requirements to your INSTALLED_APPS
in settings.py
:
INSTALLED_APPS = [
...
'crispy_forms', # for form rendering
'crispy_bootstrap5', # for Bootstrap 5 support
'crisp_modals', # for modal dialogs
'dynforms',
...
]
Include the app URLs in your project’s urls.py
:
from django.urls import path, include
urlpatterns = [
...
path('dynforms/', include('dynforms.urls')),
...
]
Create the necessary database tables by running the migrations:
python manage.py migrate
/dynforms/
.Fields can have rules associated with them, allowing for conditional logic to hide or show fields based on user input. Multiple rules can be defined for a field, and they will be evaluated in the order they are defined.
To add rules to a field, click on the "Rules" button in the field settings sidebar. Here you can define conditions that determine what action to take based on the value of other fields. Each rule consists of
Supported actions include:
Currently supported operators include:
Inherit from the abstract class BaseFormModel
, to create a model which records data from a dynamic form. This class
provides
the necessary fields and methods to handle form data. The BaseFormModel
class provides the following fields:
created
: DateTime field that records when the form was created.modified
: DateTime field that records when the form was last modified.form_type
: A Foreign key to the form.details
: A JSON field that stores the form data submitted by the user.is_complete
: A Boolean field that indicates whether the form data is complete. Partial submissions are allowed to be
saved, and the form can be completed later.Additionally, the BaseFormModel
class provides the following methods:
get_field_value(self, field_name, default=None)
: Returns the value of a specific field in the form.validate(self, data=None)
: Sets the value of a specific field in the form. The validation login uses either the
provided data or the current saved form data.The app provides a set of views to handle form display and submission.
DynFormView
: The main view for displaying and submitting forms. It handles the form rendering, validation, and
submission logic. Derive from this class to create a plain FormView not bound to a specific model. The template_name
attribute should be set to a template that includes dynforms/form.html
to render the form as desired. Submitted
form can then be handled in the form_valid
method, which can be overridden to perform custom actions. The view expects
a single pk
kwarg that corresponds to the primary key of the form type being displayed.DynCreateView
: A view for creating new forms. This is derived from django.generic.edit.CreateView
and provides a
a view form for creating a new entries of models that derive from BaseFormModel
. The form_class
attribute should
be set to a form class that inherits from DynModelForm
. As for the DynFormView
, the template_name
attribute
should be set to a template that includes dynforms/form.html
to render the form as desired. The view expects a
pk
kwarg that corresponds to the primary key of the form type being created.DynUpdateView
: A view for updating DynModelForm
entries. This is derived from django.generic.edit.UpdateView
and
provides a view for updating entries of models that derive from BaseFormModel
. The form_class
attribute should
be set to a form class that inherits from DynModelForm
. As for the DynFormView
, the template_name
attribute
should be set to a template that includes dynforms/form.html
to render the form as desired. The view expects a
pk
kwarg that corresponds to the primary key of the DynModelForm
entry being updated.To add custom fields to the form builder from another app, add a dynfields.py
module to your App's top-level
directory and define a new field inheriting from dynforms.fields.FieldType
. Implement the necessary methods to handle
rendering, validation, and type conversion.
from dynforms.fields import FieldType
from django.utils.translation import gettext_lazy as _
class CoolField(FieldType):
section = _('My Apps Fields') # This will group the field under a custom section in the field menu
name = _('Cool Field')
... # other field attributes
def render(self, context):
# Custom rendering logic
return f'<input type="text" name="{self.name}" value="{value or ""}">'
def clean(self, value, multi=False, validate=True):
"""
Custom cleaning logic for the field value.
If `validate` is True, it will perform validation on the value.
If `multi` is True, it will handle multiple values (e.g., for checkboxes).
"""
if not value:
raise ValueError('This field cannot be empty.')
return value
When defining a custom field, you can specify the following attributes:
name
: The name of the field.section
: The section under which the field will be grouped in the field menu.template_name
: The template used to render the field. If not provided, the field will try to find a template with
the same name as the slugified field class name. Alternatively, you can override the render()
method to provide
custom HTML rendering.options
: A list of options for the field, if applicable. They will be shown as checkboxes in the field form
Supported options include:
settings
: A list of settings for the field. By default, all fields will have the following settings:
render(context)
Renders the field in the given context. By default, the field is rendered using the template
specified with template_name
. This attribute can be specified directly, or the get_template_name
method can be
overridden to return the template name.
clean(value, multi=False, validate=True)
Cleans the value of the field. If validate
is True, it will
perform validation on the value and raise a Validation error on failure. If multi
is True, it will handle multiple
values (e.g., for checkboxes).
Field settings sidebar
Form Creation
List of forms
Form Builder interface showing the field menu and main designer area
Form editor showing multipage form support
Pull requests and issues are welcome!
FAQs
A Django reusable App for dynamically designing and generating forms.
We found that django-dynforms demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.