Skip to main content

django-fieldbustier

The purpose of this django-app is to allow you to add fields to models from another application.

Why this name?

Because wanting to add models from another django-app, from your own, is a bit like wanting to get on a boat and do it by shouting "All Aboard", a knife between your teeth.

And in French, a pirate is also a "flibustier", a word quite close to fieldbustier, so -> django-fieldbustier.

How to use it django-fieldbustier

you must declare the fields you want to add, modify or delete in your settings.

There are three configuration variables that are:

  • ADD_FIELD_DJANGO_FIELDBUSTIER to add fields
  • REPLACE_FIELD_DJANGO_FIELDBUSTIER to modify fields
  • DELETE_FIELD_DJANGO_FIELDBUSTIER to delete fields

To add or modify fields you must use FieldBustierConfig. To delete people you must use DeleteFieldBustierConfig.

FieldBustierConfig are namedtuple with these attributes :

  • app_name
  • model_klass
  • field_name
  • field_klass (You can use Django Field or your Field)
  • args (a tuple for positional args)
  • kwargs (a dict for keyword args)

DeleteFieldBustierConfig are namedtuple with these attributes :

  • app_name
  • model_klass
  • field_name

Add a Field

from django_fieldbustier.fieldbustier_config import FieldBustierConfig

ADD_FIELD_DJANGO_FIELDBUSTIER = [
    FieldBustierConfig(
        "demo_app",
        "DummyModel",
        "new_char_field",
        "CharField",
        ("An another CharField",),
        {"blank": True, "max_length": 200},
    )
]

Modify a Field

from django_fieldbustier.fieldbustier_config import FieldBustierConfig

REPLACE_FIELD_DJANGO_FIELDBUSTIER = [
    FieldBustierConfig(
        app_name="demo_app",
        model_klass="DummyModel",
        field_name="char_field",
        field_klass="CharField",
        args=("CharField FieldBusted !",),
        kwargs={"blank": True, "max_length": 200},
    ),
    FieldBustierConfig(
        "demo_app",
        "DummyModel",
        "decimal_field",
        "DecimalField",
        ("Decimal Field FieldBustier",),
        {"default": 2.3, "max_digits": 14, "decimal_places": 3},
    ),
]

Delete a Field

from django_fieldbustier.fieldbustier_config import FieldBustierConfig

DELETE_FIELD_DJANGO_FIELDBUSTIER = [DeleteFieldBustierConfig("demo_app",
                                                             "DummyModel",
                                                             "int_field")]

Migrations

GENERATE_FIELDBUSTIER_MIGRATIONS option

If you have used SQL to directly implement your changes, then you will not want the migrations to be generated.

To do this, you just have to set (in your settings) GENERATE_FIELDBUSTIER_MIGRATIONS at False.

Location of migration files

By default, the migration files of an application are located in the application. In our case, if you use Django-Fieldbustier, it is to avoid modifying the target application. This behavior is therefore not appropriate at all.

To avoid this, simply use django's MIGRATION_MODULES variable to choose where you want your migrations to be generated.

Thanks

Thanks for Olivier Meunier, Creme CRM codebase and Mezzanine injection Fields system for the original idea.

Metadata

Release files for django-fieldbustier 0.7.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-fieldbustier 0.7.2
File Size Uploaded
django-fieldbustier-0.7.2.tar.gz 5.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-fieldbustier 0.7.2
File Interpreter ABI Platform
django_fieldbustier-0.7.2-py3-none-any.whl Python 3 none any Details

Total release size: 10.7 kB

Release files / django-fieldbustier-0.7.2.tar.gz

Download URL django-fieldbustier-0.7.2.tar.gz
Size 5.2 kB
Tags Source
SHA-256 checksum
How to use checksums
0817ad24fe1269de43ef639c7d815e33c8a950e6908b1e4fcecef7d6069f2317
BLAKE2b-256 checksum
How to use checksums
88b6f855f1494552d47db79db1a8afd023e9518bf3fa738795427c43bd09bd7d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.3

Release files / django_fieldbustier-0.7.2-py3-none-any.whl

Download URL django_fieldbustier-0.7.2-py3-none-any.whl
Size 5.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d0eef418eb30c6bedf1674cace3fab7f3fa7213fb0473191f70def4f86080438
BLAKE2b-256 checksum
How to use checksums
e98956e0f09992d1bda4c79e14d2f2f97896b09f3f9790b617a53b82de21ffaf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.3

Release history Release notifications | RSS feed

1.0.0

1 release file

0.9.0

1 release file

0.8.0

2 release files

This release

0.7.2 This release

2 release files

0.7.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page