Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Q: Persisting models to Django ORM? #146

Open
Natureshadow opened this issue Mar 2, 2021 · 1 comment
Open

Q: Persisting models to Django ORM? #146

Natureshadow opened this issue Mar 2, 2021 · 1 comment
Labels

Comments

@Natureshadow
Copy link

I am developing a library that handles data that is exchanged in JSON format. It shall be designed to be easily usable with Django, but not require it.

jsonmodels seems like a good fit to start the modelling process. Has anyone thought about how to link it to Django ORM, as in, optionally persist data in real Django models?

@beregond
Copy link
Collaborator

beregond commented Mar 4, 2021

Hey @Natureshadow

If you are creating lib, of which jsonmodels would be a transport layer with optional Django support - then I suggest to put code (in the beginning at least) responsible for that in that very library (as jsonmodels does not have any integration with any framework for now).

As the lib grows - you could make this generic - and extract this as a plugin to your library (or jsonmodels?)

And diving into more details about

Has anyone thought about how to link it to Django ORM, as in, optionally persist data in real Django models?

I'd keep jsonmodels and Django agnostic - and build around them layer that translates/autogenerates models (field by field) - although this is complicated as you can have few approaches like keeping only one-level models (so they are easily translated) or cast deeper json structures as json field or as related model... Plus there is problem how to handle django migrations (especially that Django has to be optional).

So yeah, problem is complicated - you should start with as many constraints and assumptions as possible to make this easier :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants