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

Allow posting a model with single related model #83

Merged
merged 1 commit into from Jul 31, 2012

Conversation

mkuprionis
Copy link
Contributor

I.e. when relation is many-to-one or one-to-one (model being posted belongs-to or has a related object).

Current implementation expects to get a list of related objects.

I.e. when relation is many-to-one or one-to-one (model being posted belongs-to or has related object).
@remaerd
Copy link

remaerd commented Jul 25, 2012

You should look at the docs more carefully. you can use uselist=False to create an one-to-one relationship. http://packages.python.org/Flask-SQLAlchemy/models.html#one-to-many-relationships

@mkuprionis
Copy link
Contributor Author

Please check the changeset.

There's no problem with SQLAlchemy nor with defining one-to-one relationship, problem is with what Flask-Restless expects relationship to be. Currently it expects that if I post model with a relation, that relation must be a list of related objects. So trying to POST data like below will fail:

{
  'vendor': u'Apple', 
  'name': u'iMac', 
  'owner': {'name': u'John', 'age': 2041}
}

@jfinkels
Copy link
Owner

Thanks for this, I will check it out, test it, and then pull it in.

jfinkels added a commit that referenced this pull request Jul 31, 2012
Allow posting a model with single related model
@jfinkels jfinkels merged commit 808208c into jfinkels:master Jul 31, 2012
jfinkels added a commit that referenced this pull request Jul 31, 2012
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

Successfully merging this pull request may close these issues.

None yet

3 participants