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

More comprehensive explanation of Relationship Fields? #1028

Closed
danielniccoli opened this issue Sep 13, 2013 · 1 comment
Closed

More comprehensive explanation of Relationship Fields? #1028

danielniccoli opened this issue Sep 13, 2013 · 1 comment

Comments

@danielniccoli
Copy link

I am new to Tastypie and I am trying to understand how to query relationships.

I read Creating more Resources. It is unclear for me what the second parameter 'user' really does in line user = fields.ForeignKey(UserResource, 'user'). I flicked to Relationship Fields and read it but I could not find any clue about it. I was expecting kind of a list of parameters with explanations 😕

That makes it even harder to understand the next step: many-to-many relationships.

@ondrowan
Copy link
Contributor

Relationship fields inherit parameters of basic API fields. In this case user is attribute parameter:

A string naming an instance attribute of the object wrapped by the Resource. The attribute will be accessed during the dehydrate or or written during the hydrate.

If your resource contains queryset = Note.objects.all(), user will be user field of Note model instance. It's very similar with m2m relationships.

I agree that documentation could be improved here. I'd say, let's keep this issue open and I'm sure it'll be fixed sooner or later.

saedmansour pushed a commit to segmanta/django-tastypie that referenced this issue Dec 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants