Package: django-fieldbustier
django-fieldbustierThe purpose of this django-app is to allow you to add, delete, or modify fields in models from third-party applications outside of your django project.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 django-fieldbustierFirst, add "django_fieldbustier" to your installed apps, above any apps that you intend to modify.Then, 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 fieldsREPLACE_FIELD_DJANGO_FIELDBUSTIER to modify fieldsDELETE_FIELD_DJANGO_FIELDBUSTIER to delete fieldsTo add or modify fields you must useFieldBustierConfig. To delete fields you must useDeleteFieldBustierConfig.FieldBustierConfigarenamedtuplewith these attributes :app_namemodel_klassfield_namefield_klass (You can use Django Field or your Field)args (a tuple for positional args)kwargs (a dict for keyword args)DeleteFieldBustierConfigarenamedtuplewith these attributes :app_namemodel_klassfield_nameAdd a Fieldfrom 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 Fieldfrom 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 Fieldfrom django_fieldbustier.fieldbustier_config import FieldBustierConfig

DELETE_FIELD_DJANGO_FIELDBUSTIER = [DeleteFieldBustierConfig("demo_app",
                                                             "DummyModel",
                                                             "int_field")]MigrationsGENERATE_FIELDBUSTIER_MIGRATIONS optionIf 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 to False.Location of migration filesBy default, the migration files of an application are located in the application. In our case, if you use Django-Fieldbustier, we want to avoid modifying the target application. The default 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. Ideally, this should be done at the beginning of a project to avoid issues.For instance, if editing a model in the built-in django appauth, we might want to save the migrations in our localusersapp. In this case, we could add the following to settings:MIGRATION_MODULES = {'auth': 'users.migrations_auth'}This requires copying the originalauthmigrations to themigrations_authfolder inside yourusersapp. Now your project will look for (and add) migrations files for theauthapp in themigrations_authfolder inside yourusersapp.ThanksThanks for Olivier Meunier, Creme CRM codebase and Mezzanine injection Fields system for the original idea.