A Django library for generating dynamic forms, views, and templates.
Project description
DFormKit
DFormKit is a Python library designed to help Django developers dynamically generate forms, manage views, and streamline template creation based on Django models.
Why DFormKit?
This command-line wizard lets you dynamically generate forms, templates, views, and URL patterns for your Django models straight from your Terminal. It works seamlessly on Windows, Mac, and Linux, so you can use it on any platform.
While other tools make you wade through a swamp of settings and configurations, DFormKit keeps it simple. Just specify your app and model, and voilà! It’ll take you on a smooth ride to creating dynamic forms, no complex options needed—just fun coding! 🔥
Features
- Dynamic Form Generation: Automatically generate forms from Django models.
- Template Creation: Create HTML templates for forms.
- View Integration: Add view functions and URL patterns dynamically.
- Customizable Templates: Supports integrating styling frameworks like Tailwind CSS.
🛠️ Installation
-
Install the library using
pip:pip install dformkit
-
Add
'dformkit'toINSTALLED_APPSin your Django project'ssettings.pyfile:INSTALLED_APPS = [ ..., 'dformkit', ]
(Insert an image showing the addition of
'dformkit'toINSTALLED_APPSinsettings.py.)
📈 Upgrade
Stay in the loop with the latest features on GitHub! To upgrade your DFormKit tool, simply run:
pip install --upgrade dformkit
Then you’re all set to keep generating dynamic forms from your Terminal! 🥳
🦸 Quick Start
Getting started with DFormKit is a piece of cake! Just use the following command style:
python manage.py dformkit myapp Person
Note:
- Replace
myappwith your Django app name. - Replace
Personwith your model name.
If you don’t specify additional options, it’ll generate a dynamic form for the model and save it in forms.py. Easy-peasy!
👨💻 Usage
Arguments
| Argument | Description |
|---|---|
app |
The name of your Django app. This argument is [Required]. |
model |
The name of your Django model. This argument is [Required]. |
Options
| Option | Description |
|---|---|
-page or --p |
Generate an HTML template for the form. |
-view or --v |
Add a view function to views.py and a URL pattern to urls.py. |
--pv or --vp |
Combine all options: generate the form, template, view, and URL pattern. |
Examples
1. Generate a Form Only
python manage.py dformkit myapp Person
- What it does: Generates a dynamic form for the
Personmodel in themyappapplication. - Output: The form is saved in
forms.py.
(Insert an image showing the terminal command and the generated form in forms.py.)
2. Generate a Form and Template
python manage.py dformkit myapp Person -page
or
python manage.py dformkit myapp Person --p
- What it does: Generates the form and an HTML template for it.
- Output: The form is saved in
forms.py, and the template is saved in thetemplatesfolder.
(Insert an image showing the terminal command and the generated HTML template.)
3. Generate a Form, View, and URL Pattern
python manage.py dformkit myapp Person -view
or
python manage.py dformkit myapp Person --v
- What it does: Generates the form, adds a view function to
views.py, and adds a URL pattern tourls.py. - Output: The form, view, and URL pattern are created.
(Insert an image showing the terminal command and the modifications in views.py and urls.py.)
4. Combine All Options
python manage.py dformkit myapp Person --pv
or
python manage.py dformkit myapp Person --vp
- What it does: Combines all the above steps into one command.
- Output: The form, template, view, and URL pattern are generated.
(Insert an image showing the combined terminal command and the resulting changes in all relevant files.)
🧰 Additional Features
Using Named Arguments
You can use named arguments for more flexibility. For example:
python manage.py dformkit -app=myapp -model=Person -view
or
python manage.py dformkit -app=myapp -model=Person --pv
- What it does: Works the same as positional arguments but provides a more explicit way to specify the app and model.
Overwriting Existing Forms
If the form already exists in forms.py, the library will warn you before overwriting it. You can choose to proceed or skip.
Customizing Templates
The generated templates are fully customizable. You can integrate styling frameworks like Tailwind CSS or Bootstrap by modifying the generated HTML files.
Testing the Library
You can run unit tests using pytest:
pytest
(Insert an image showing the tests running successfully in the terminal.)
Contributing
We welcome contributions! Follow these steps:
- Fork the repository.
- Create a new branch for your feature or fix.
- Write tests if applicable.
- Submit a Pull Request with details about your changes.
(Insert an image showing the GitHub fork and pull request process.)
❓ Frequently Asked Questions (FAQ)
1. What happens if the form already exists in forms.py?
- If the form already exists, the library will warn you before overwriting it. You can choose to proceed or skip.
2. Can I customize the generated templates?
- Yes, the generated templates are fully customizable. You can integrate styling frameworks like Tailwind CSS or Bootstrap.
3. How do I add validation to the form?
- Validation is automatically handled based on the constraints defined in your Django model (e.g.,
max_length,null,blank, etc.).
🚀 Conclusion
DFormKit simplifies the process of generating forms, templates, views, and URL patterns in Django. By following the steps above, you can quickly set up dynamic forms for your models and streamline your development workflow.
📜 License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dformkit-0.1.0.tar.gz.
File metadata
- Download URL: dformkit-0.1.0.tar.gz
- Upload date:
- Size: 14.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f91bf4c043609d6a2b5dc423677dc6c524b57f08de12c0e3c62959e23fc82a9c
|
|
| MD5 |
ca287d30239a28f3a75674ce96ca22fe
|
|
| BLAKE2b-256 |
b1c0ffd2f3894ad2143b636f3583c3f259a83aa1311b6927fe0fa24eb45eddad
|
File details
Details for the file dformkit-0.1.0-py3-none-any.whl.
File metadata
- Download URL: dformkit-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e40893326e04c0ce2517f7b3213b78a39d158b7c7552d2befa73acf606e088e0
|
|
| MD5 |
a4faf164322e8c07eda3cd4a0c1db674
|
|
| BLAKE2b-256 |
55d8c19f0db1fa35c5d62b44a8ca021159fd1e22043b04cb572d26d58b9a30dd
|