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

List of ForeignKey (List of reference to other objects) #9

Open
kfrancoi opened this issue Feb 24, 2012 · 6 comments
Open

List of ForeignKey (List of reference to other objects) #9

kfrancoi opened this issue Feb 24, 2012 · 6 comments

Comments

@kfrancoi
Copy link

Hello

I just posted a question on Stackoverflow related to the possibility for a Resource to resolve a list of ForeignKey (Object ID) to other objects and make it accessible in the API.

http://stackoverflow.com/questions/9434823/django-mongodb-tastypie-nonrel-list-of-foreignkey

I think this would be a very useful feature for tastypie-nonrel. Do you agree ?

Thank you

@kfrancoi
Copy link
Author

I don't understand why there is not way to have field that encapsulate list of ForeignKey. If I'm not misunderstanding, I think it is a common pattern in NoSQL ? EmbeddedModel place an object A inside another objectB, but any modification on the object A independently of the object B will not be reflect in the object B.A. With a list of ForeignKey in the object B containing references to objects A will ensure that consistency.

Are you OK with that ? I want to be sure I'm understanding NoSQL correctly :-)

http://stackoverflow.com/questions/9434823/django-mongodb-tastypie-nonrel-list-of-foreignkey

Thanks

@jonashaag
Copy link

Sure, it's an idiomatic pattern -- IIRC it works in Django. (I don't know about tastypie though)

@kfrancoi
Copy link
Author

kfrancoi commented Mar 1, 2012

Thanks,

However, I can't find a reference to a Django documentation where it's shown how to handle a list of ForeignKey ?

Basically, what I'm trying to develop is a new field for django-tastypie-nonrel that act as a EmbeddedListField but access sub-object by reference (using ForeignKey) instead of embedding them.

Any comment on that is welcome.

@kfrancoi
Copy link
Author

kfrancoi commented Mar 5, 2012

Hi,

I solved my problem by writing a new tastypie-nonrel field to handle list of ForeignKey. If contributors of this project are interested, I'm happy to discuss on how we could integrate this in a future version.

Thanks

@andresdouglas
Copy link
Owner

@kfrancoi sorry for the slow reply. I haven't looked at that specific problem in a while, but I remember there was something problematic about it. Do you have a patch for it? We also need to merge tastypie-nonrel with a more current version of tastypie, since there have been some major changes in the parent project.

@kfrancoi
Copy link
Author

@andresdouglas thanks for your answer. I think I solved the need to have a list of foreignKey to other models, based on your work. It has been tested for both GET and POST requests. I think Tastypie is a very good product, and there is a clear need to extend that it's functionality to nonrel databases.
So please, don't hesitate to put me in the loop if you want to improve your project (-> tastypie-nonrel).

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

3 participants