Git Product home page Git Product logo

Comments (12)

bhch avatar bhch commented on May 24, 2024 4

@danihodovic I will try to add these features in the next release. These days I'm caught up in some other things, but hopefully by mid to late February.

from django-jsonform.

danihodovic avatar danihodovic commented on May 24, 2024 2

@bhch Many thanks for this excellent library. It's one of the best tools I've found for unstructured data (with a user interface). I'm using it for field translations, but I can think of a dozen other use-cases for early stage prototyping. This project deserves more attention.

from django-jsonform.

gersmann avatar gersmann commented on May 24, 2024 1

Worked like a charm on my test schema. Very nice, thats a game changer for working with Pydantic in Django.

from django-jsonform.

bhch avatar bhch commented on May 24, 2024

Yeah, currently I've implemented a custom, non-standard json schema specification. But I'm working towards adding the standard features. I've got some features lined up for the next release (like referencing and recursive nesting). I'll try to include allOf/anyOf/oneOf also. I'll have to see.

Currently, for basic string based options, you can use the choices keyword. And for anyOf type options, there's a multiselect widget.

from django-jsonform.

bhch avatar bhch commented on May 24, 2024

I'm starting work on this. But these keywords - allOf/anyOf/oneOf - are mainly for validation and I'm having a hard time trying to figure out how to render a form for them.

If you can give me a couple of example schemas for them and describe the form's expected behaviour, it will make things a bit easier for me. Thanks.

from django-jsonform.

bhch avatar bhch commented on May 24, 2024

@n0rdlicht Hi, I'm still waiting for suggestions from you. Please, see my previous comment. Thank you.

from django-jsonform.

danihodovic avatar danihodovic commented on May 24, 2024

oneOf is useful as it allows us to map Django TextChoices cleanly to a select field. Otherwise one must use the pre_save_hook to transform the choice label to the choice value.

from django-jsonform.

gersmann avatar gersmann commented on May 24, 2024

A great use case for this would be to build forms for variable field sets for inheritance-simiar discriminated unions, as they are for instance implemented by Pydantic.
https://docs.pydantic.dev/usage/types/#discriminated-unions-aka-tagged-unions

This is a very common JSON/JSON Schema pattern.

from django-jsonform.

bhch avatar bhch commented on May 24, 2024

@gersmann I'm working on this. I've got about half of this done. I'll try to get a beta out this weekend for some feedback.

from django-jsonform.

bhch avatar bhch commented on May 24, 2024

Hello, everyone participating in this thread!

I've just implemented this feature on the JS side. You can test it out in the playground here: https://bhch.github.io/react-json-form/playground/#18-anyof.

I encourage you to kindly test with your own schemas because there might be certain cases which I've forgot to account for. If you do find any bugs, please report. But any sort of feedback is appreciated.

I'll release the Django app next weekend.

Thank you.

from django-jsonform.

bhch avatar bhch commented on May 24, 2024

This feature has been implemented across multiple commits:

Will be released shortly.

from django-jsonform.

bhch avatar bhch commented on May 24, 2024

This feature has been released in v2.16.0. Please update and test it out.

There are a few limitations in the implementation, so do read the docs as well.

Thank you.

from django-jsonform.

Related Issues (20)

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.