Skip to content

Instant validation of data is giving me more headache that benefit #71

@andreasnuesslein

Description

@andreasnuesslein

Ahoy there 👋

So, I really like(d) the idea that fields are instantaneously validated when you write them or read them. But it does give a lot of headaches in various places. Every time you try to change the schema, you basically have to empty the database.

I now tried to create a migration but even there, I can't really access the fields because I get validation errors:

def forward_carbon_sequ(apps, _schema_editor):
    DealVersion = apps.get_model("landmatrix", "DealVersion")
    for dv in DealVersion.objects.all():
        print(dv.carbon_sequestration)

def reverse_carbon_sequ(apps, _schema_editor):
    DealVersion = apps.get_model("landmatrix", "DealVersion")
    for dv in DealVersion.objects.all():
        print(dv.carbon_sequestration)

class Migration(migrations.Migration):
    dependencies = [  ]

    operations = [
        migrations.RunPython(forward_carbon_sequ, reverse_carbon_sequ),

    ]

For one attribute I need to switch from Enum to list[Enum] but obviously it's complaining

django.core.exceptions.ValidationError: ['[{"type":"list_type","loc":[0,"certification_standard_name"],"msg":"Input should be a valid list","input":"OTHER",

So, again: I liked the instant validation but I fear it makes things harder than they need to be. As far as I know, there are no other fields that do that. Normally you can put in any data you like and only on model .save() it will validate the payload.

What is your take on this?

PS: I think this is connected to #35 too

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions