
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
django-forms-fieldset
Advanced tools
Django form fieldset inspire django admin fieldset
pip install django-forms-fieldset
settings
Add forms_fieldset
to your INSTALLED_APPS setting like this:
INSTALLED_APPS = [
...
'forms_fieldset',
]
load template
{% load forms_fieldset static %}
<link rel="stylesheet" type="text/css" href="{% static 'forms_fieldset/css/main.css' %}">
<form>
{{ form|fieldset:'#42945c' }}
</form>
Note : The fieldset filter receives the color of the titles of the form groups, by default this color is used: # 79AEC8)
models
from django.db import models
# Create your models here.
class Student(models.Model):
first_name = models.CharField(max_length=200, verbose_name="First Name")
last_name = models.CharField(max_length=200, verbose_name="Last Name")
email = models.EmailField(unique=True, verbose_name="Email")
adress = models.CharField(max_length=200, verbose_name="Adress")
mother_name = models.CharField(max_length=200, verbose_name="Mother Name")
father_name = models.CharField(max_length=200, verbose_name="Father Name")
class Note(models.Model):
SUBJECTS = (
('Math', 'Math'),
('French', 'French'),
('Physical', 'Physical'),
)
student = models.ForeignKey('Student', on_delete=models.CASCADE, related_name="notes")
subject = models.CharField(max_length=200, choices=SUBJECTS, verbose_name="Subject")
value = models.IntegerField(verbose_name="Notation")
class Meta:
verbose_name = "Les notes"
verbose_name_plural = "Les notes"
forms
from django.forms import ModelForm
from .models import Student
class StudentForm(ModelForm):
fieldsets = [
("Student Information", {'fields': [
('first_name', 'last_name'),
('email', 'adress'),
]}),
("Parent Information", {'fields': [
'mother_name',
'father_name',
]}),
]
class Meta:
model = Student
fields = '__all__'
views
from django.shortcuts import render
from django.forms import inlineformset_factory
from .forms import StudentForm
from .models import Student, Note
# Create your views here.
def home(request):
form = StudentForm()
InlineForm = inlineformset_factory(Student, Note,
fields=('subject', 'value',), exclude=('pk',), can_delete=False,
)
if request.method == 'POST':
form = Form(request.POST, request.FILES)
formset = InlineForm(request.POST, request.FILES)
#save...
context = {
'form': form,
'inline_form': InlineForm()
}
return render(request, 'home.html', context)
template
{% load forms_fieldset static %}
<!DOCTYPE html>
<html>
<head>
<title>Home page</title>
<link rel="stylesheet" type="text/css" href="{% static 'forms_fieldset/css/main.css' %}">
</head>
<body style="width: 75%; margin: 50px auto">
<h1>Student form information</h1>
<form>
{{ form|fieldset:'#42945c' }}
{{ form_inline|inline_fieldset:"#42945c,Note des eleves" }}
</form>
</body>
</html>
enjoy
FAQs
Django form fieldset inspire django admin fieldset.
We found that django-forms-fieldset 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
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
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.