Giter VIP home page Giter VIP logo

Comments (3)

pySilver avatar pySilver commented on September 27, 2024

Nah. That's not a good idea to use mode="json" since we may want to use callable(s) in settings. So probably the only viable solution is to include all known types from pydantic_core and modify to_django so it can handle additional types conversions.

from pydjantic.

erhosen avatar erhosen commented on September 27, 2024

So probably the only viable solution is to include all known types from pydantic_core and modify to_django so it can handle additional types conversions.

Do I understand correctly that you're suggesting adding custom handlers for non-standard Pydantic types (like Url, NameEmail, etc.), similar to how we handle SecretStr and SecretBytes here?

elif isinstance(val, SecretStr) or isinstance(val, SecretBytes):
return val.get_secret_value()

If that's the case, I have no objections. It seems like a logical development for the library, and I'd be grateful if you could create the appropriate patch to address your issue.

In turn, I’ll promptly review it and release a new version to PyPI!

from pydjantic.

pySilver avatar pySilver commented on September 27, 2024

Yeah. Unfortunately I haven't found any better solution other than handling custom types manually within 'to_django' function. It's not nice but there is no better way to do it at the moment.

from pydjantic.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.