Django-Hacker: customize default django forms
Project description
Basic usage
Install with pip install djhacker and then:
import djhacker
djhacker.formfield(
YourModel.your_field,
YourFormField,
custom_form_field_kwarg='something',
)
This will make any Django ModelForm render a YourFormField(custom_form_field_kwarg='something') by default, plus whatever other kwargs it wants to add, you won’t have to use any specific model form, this will work natively in the admin for instance.
Registry
You can register custom form field for model field types:
@djhacker.register(models.ForeignKey)
def custom_fk_formfield(model_field):
return YourFormField, dict(
custom_form_field_kwarg='something',
)
# you don't need to pass extra arguments anymore for ForeignKey fields:
djhacker.formfield(YourModel.some_fk)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
djhacker-0.0.1.tar.gz
(1.9 kB
view details)
File details
Details for the file djhacker-0.0.1.tar.gz
.
File metadata
- Download URL: djhacker-0.0.1.tar.gz
- Upload date:
- Size: 1.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.26.0 setuptools/57.4.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 14ba2f9ac0351e3c6e01841754febb8497ebb1a16edcec41580c3220468fa532 |
|
MD5 | ee2716681e142538fa587c1beea9cfaf |
|
BLAKE2b-256 | f41d604afd9f8ac5871c6a51ddf8c1dbad394e916217edb57974a9463ccf48b0 |