Giter Club home page Giter Club logo

Comments (3)

vitalik avatar vitalik commented on May 18, 2024

Hi Jordan,

Looks like you working on a feature that I currently researching for a project django-ninja

https://github.com/vitalik/django-ninja

Specifically for now I'm just trying to develop usable/nice API for conecting Pydantic model and Django model

https://django-ninja.rest-framework.com/proposals/models/


I like your concept...
but I see particcular problem in adding too much methods to model namespace like:

user_schema = UserSchema.from_django(user)

user_schema = UserSchema.get(id=user.id)

UserSchema.create(...)


What I think the best is having some single attribute to access ORM:


UserSchema.objects --> will map to User.objects

so now you should be able to do

UserSchema.objects.get(...

UserSchema.objects.filter(...).first()


from djantic.

jordaneremieff avatar jordaneremieff commented on May 18, 2024

@vitalik I prefer that approach (single attribute access) and used it initially, but there is a difficult problem of chaining additional filter methods and accomodating custom manager methods so I opted to instead provide only basic queryset access with the intention that more complex queries would be performed using just Django ORM first then loaded into the model. I haven’t had a lot of time to look at this lately, but that is something I’ll probably revisit when I look into this next.

from djantic.

jordaneremieff avatar jordaneremieff commented on May 18, 2024

I think for now I'll leave it up to users to integrate the models with their endpoint views.

from djantic.

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.