django-forms-fieldset
Django form fieldset inspire django admin fieldset
Installation
pip install django-forms-fieldset
Usage
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)
Complete Guide
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
Features
- Fieldset django form
- Fieldset (tabular style) inline form
Credit
Harouna Diallo
Metadata
Release files for django-forms-fieldset 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-forms-fieldset-1.0.2.tar.gz | 280.7 kB | Without provenance | Details for django-forms-fieldset-1.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_forms_fieldset-1.0.2-py3-none-any.whl | Python 3 | none | any | Details for django_forms_fieldset-1.0.2-py3-none-any.whl |
Total release size: 568.2 kB
Release files / django-forms-fieldset-1.0.2.tar.gz
| Download URL | django-forms-fieldset-1.0.2.tar.gz |
|---|---|
| Size | 280.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1fae913a9d83d1c243e8c2ba685ff70f6d6039828be9a4178b3e276dc75a2cc0
|
|
BLAKE2b-256 checksum How to use checksums |
ffb78e1bec26238fe80afe73113b6241b2efe4b9b8254a149cef061f77358b9c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.8.10
|
Release files / django_forms_fieldset-1.0.2-py3-none-any.whl
| Download URL | django_forms_fieldset-1.0.2-py3-none-any.whl |
|---|---|
| Size | 287.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4b96537c4fec076a5036437cd7bb6981b930d3b3815246515b8df0730cb8df80
|
|
BLAKE2b-256 checksum How to use checksums |
799bcb2f7057da81f0357973d20faa301edfd8012c6787825d7988f0039cdb38
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.8.10
|
Security for django-forms-fieldset 1.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.