Skip to content

How to skip an intermediary model? #97

Answered by j4mie
carltongibson asked this question in Q&A
Discussion options

You must be logged in to vote

Not really an answer as such, but here's a slightly higher-level way to achieve the thing you were trying to do:

spec = [
    ...
    {
        "owner_group": (
            pairs.discard_projector(
                specs.relationship(
                    "owner",
                    [{"group": ["name"]}],
                    to_attr="owner_for_owner_group",
                )
            ),
            projectors.producer_to_projector(
                "name", producers.attr("owner_for_owner_group.group.name")
            )
        )
    },
    ...
]
  • We use a spec to express the relationship to avoid manually building the queryset function, including specifying a custom to_attr so we don't …

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@carltongibson
Comment options

@carltongibson
Comment options

Comment options

You must be logged in to vote
1 reply
@carltongibson
Comment options

Answer selected by carltongibson
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants