Coder Social home page Coder Social logo

Comments (6)

tomchristie avatar tomchristie commented on May 23, 2024

Just needs documenting

from django-rest-framework.

ulmus avatar ulmus commented on May 23, 2024

Any chance of this landing in trunk soon? It gets tedious to spec all relations using the ("resource", ("title", "description"...)) -syntax :)

from django-rest-framework.

tomchristie avatar tomchristie commented on May 23, 2024

See tests/serializer.py - test_serializer_class_nesting and test_serializer_classname_nesting.
You can just use a two tuple of the field name that's nested, and the Resource you want to use for the nesting.
I think that'll do exactly what you're looking for (? tho let me know if not...) - I'm just struggling to find the time outside of work to work on the documentation a bit.

from django-rest-framework.

ulmus avatar ulmus commented on May 23, 2024

Yup, I finally got around to looking through the source (and found the bug in issue 53 :))
I'd be glad to help out on the documentation if I weren't also swamped in work, doing double shifts atm...

from django-rest-framework.

dokkaebi avatar dokkaebi commented on May 23, 2024

It is a little cumbersome to specify a Resource for a given fk field, because you must then specify all fields. It would be useful to offer a merge, so that we could specify a Resource for one field and still use the defaults for the remaining fields. I accomplish this with something like

  fields=[('user',UserResource) if f.name is 'user' else f.name for f in Player._meta.fields]

but offering something like

fields_to_merge=[('user', UserResource)] 

to the same effect would be handy.

from django-rest-framework.

tomchristie avatar tomchristie commented on May 23, 2024

@dokkaebi - You can use .include and .exclude, although it's a good example of how it being undocumented at the moment. Try include = [('user', UserResource)]

from django-rest-framework.

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.