https://github.com/abdelhadi92/sitech-different-formset
Beautifully Django library to work with different forms on the same page.
https://github.com/abdelhadi92/sitech-different-formset
Last synced: 3 months ago
JSON representation
Beautifully Django library to work with different forms on the same page.
- Host: GitHub
- URL: https://github.com/abdelhadi92/sitech-different-formset
- Owner: Abdelhadi92
- License: mit
- Created: 2019-11-14T00:20:56.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-11-14T00:21:14.000Z (over 5 years ago)
- Last Synced: 2025-01-18T00:14:41.871Z (5 months ago)
- Language: Python
- Homepage:
- Size: 22.5 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Sitech-different-formset
A formset is a layer of abstraction to work with diffrent forms on the same page.### Installation
Run the [pip](https://pip.pypa.io/en/stable/) command to install the latest version:
```bash
pip install git+https://github.com/sitmena/[email protected]
```### Usage
```python
# in views.py
from sitech_different_formset import different_formset_factoryTestFormSet = different_formset_factory(Form1, Form2, {'model': User, 'fields': ['field1_name', 'field2_name']})
formset = TestFormSet(request.POST, initil={'Form1': ..., 'UserForm': ...}, instances={'UserForm': ...} )for form in formset:
print(form.as_table())print(formset.Form1)
print(formset.UserForm)# in template.html
{{ formset.Form1.field_name|as_crispy_field:"bootstrap4" }}
{{ formset.UserForm.field_name|as_crispy_field:"bootstrap4" }}
```