Skip to main content

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.1.0.tar.gz (2.0 kB view details)

Uploaded Source

File details

Details for the file djhacker-0.1.0.tar.gz.

File metadata

  • Download URL: djhacker-0.1.0.tar.gz
  • Upload date:
  • Size: 2.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for djhacker-0.1.0.tar.gz
Algorithm Hash digest
SHA256 eab510850bc0099dee9ef04031c5935a52472d7eed556a3678f8213d24afa915
MD5 2d82c459475cfe0ac76e16d74de195cc
BLAKE2b-256 44a8bafe31928faee9c67a35e32fd9e54058085aceb5429278e1c8892b3c2f31

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page