Giter VIP home page Giter VIP logo

ember-drf's People

Contributors

craigteegarden avatar g-cassie avatar martinmaillard avatar thegrymek avatar vecdeque avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ember-drf's Issues

`ActiveModelJSONRenderer` import error, `ManyRelation` is not introduced until DRF 3.0

An error occurs when trying to use ember_drf.renderers.ActiveModelJSONRenderer with Django-Rest-Framework 3.0 beta. It seems like ManyRelation, imported in ember_drf.utils, is not included in the 3.0 beta, but is present on the 3.0 branch.

ImportError: Could not import 'ember_drf.renderers.ActiveModelJSONRenderer' for API setting 'DEFAULT_RENDERER_CLASSES'. ImportError: cannot import name ManyRelation.

Is there anything I can do ?

Support non-database fields

Hi, I have a model which has some nested relations, something like:

class Document(models.Model):
    node_positions = models.ManyToMany('NodePosition')

    def get_nodes(self):
        return Node.objects.filter(node_position__document=self)

class NodePosition(models.Model):
    node = models.ForeignKey('Node')

class Node(models.Model):
    pass

and I would like, when fetching a document, to sideload both NodePositions and Nodes. However, due to the way the SideloadSerializer is implemented, it depends on django-reported relations, which don't include Nodes. So if my DocumentBaseSerializer does

class DocumentBaseSerializer(serializers.ModelSerializer):
    nodes = serializers.ReadOnlyField(source='get_nodes')

I get the node IDs but I am not able to sideload the nodes. I am thinking of overriding _configure_sideloads to try and support this use case as well, but I'm wondering if you have tried this before or have any input on the matter. Thanks!

Multi-level relationships with sideloaded json

Hi,
I'd like to sideload data with multi-level relationships such as :

{
    "workoutPlan": {
        "id": 1999,
        "name": "Test Plan",
        "workout_ids": [ 12452, 12453 ],
    },
    "workouts": [
        {
            "id": 12452,
            "exercise_ids": [ 114322 ]
        },  {
            "id": 12453,
            "exercise_ids": [ 114323 ]
        }
    ],
    "exercises": [
        { "id": 114322 },
        { "id": 114323 }
    ]
} 

I tried to call the SideloadSerializer into sideloads:

class WorkoutPlanSideloadSerializer(SideloadSerializer):
    class Meta:
        base_serializer = WorkoutPlanSerializer
        sideloads = [
            (Workout,  WorkoutSideloadSerializer)
        ]

class WorkoutSideloadSerializer(SideloadSerializer):
    class Meta:
        base_serializer = WorkoutSerializer
        sideloads = [
                (Exercise, ExerciseSerializer)
        ]

But I get something like:

{
    "workoutPlan": {
        "id": 1999,
        "name": "Test Plan",
        "workout_ids": [ 12452, 12453 ],
    },
    "workouts": {
        "workouts": [
            {
                "id": 12452,
                "exercise_ids": [ 114322 ]
            },  {
                "id": 12453,
                "exercise_ids": [ 114323 ]
            }
        ],
        "exercises": [
            { "id": 114322 },
            { "id": 114323 }
        ]
    },
} 

Is there a way to get the correct json output ?
Thank you !

ValueError on models with OneToOneField that is set a related_name

If I have the following models:

class BigThing(models.Model):
    name = models.CharField(max_length=100)
    favorite = models.OneToOneField('ChildThing', related_name='favorite_of')

class ChildThing(models.Model):
    father = models.ForeignKey(BigThing)
    name = models.CharField(max_length=100)

A ValueError is raised even if I'm not including the field favorite_of in the ChildThingSerializer.
error

Made a commit to the same repo to show the problem. https://github.com/wichovw/emberdrf-sideload-example

Thnx!!!

ActiveModelJSONRenderer cannot work without nested ReturnDicts

As discussed in #1 the ActiveModelJSONRenderer is currently broken due to ReturnDict instances no longer being nested.

I have a PR into DRF here encode/django-rest-framework#2119 and at this stage am optimistic that we can get the needed changes made in the short term. If that discussion appears to stagnate I will look for a work around (though it will either involve modifying DRF or moving behaviour into the serializer).

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.