django-ninja icon indicating copy to clipboard operation
django-ninja copied to clipboard

[BUG] @model_validator(mode="before") issue

Open shughes-uk opened this issue 7 months ago • 2 comments

Describe the bug

When using something like this, values is a DjangoGetter instance which is somewhat unexpected to me. Prior to 1.0 and the pydantic update you would get a plain dictionary.

class SomeSchema(Schema):
     somevar:int

    @model_validator(mode="before")
    @classmethod
    def foo(cls, values):
        values.get("something")

Versions (please complete the following information):

  • Python version: 3.10
  • Django version: 4.1
  • Django-Ninja version: 1.0.1
  • Pydantic version: 2.5.1

shughes-uk avatar Nov 20 '23 23:11 shughes-uk

Note to myself: maybe adding dict methods to DjangoGetter will work

vitalik avatar Nov 21 '23 10:11 vitalik

Hey @vitalik, any word on this? We're trying to upgrade to 1.1.0 and blocked by this. Thinking of submitting a PR depending on complex it is.

agraham-oni avatar Dec 21 '23 05:12 agraham-oni