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

Cannot POST data with a hybrid_attribute column #320

patrickyan opened this issue Jun 5, 2014 · 4 comments

Cannot POST data with a hybrid_attribute column #320

patrickyan opened this issue Jun 5, 2014 · 4 comments


Copy link

@patrickyan patrickyan commented Jun 5, 2014

Problem described here

Flask-Restless gives me a 400 and says Model does not have field 'address'. The weird thing is that I can expose the same property in my API through the include_columns parameter.

I have another hybrid_property that I am setting as well, but it doesn't complain about that. I can't figure out what's wrong with this hybrid_property

@jfinkels jfinkels added the bug label Jun 13, 2014
Copy link

@jfinkels jfinkels commented Jun 13, 2014

Maybe this is related to #319 ? I'm not sure off the top of my head. Can you provide a gist with a small example that shows this behavior?


Copy link

@TimotheeJeannin TimotheeJeannin commented Oct 1, 2014

I'm experiencing this problem too.
Here is a small example to reproduce it:

import os
import flask
import flask.ext.sqlalchemy
import flask.ext.restless
from sqlalchemy.ext.hybrid import hybrid_property

app = flask.Flask(__name__)
app.config['DEBUG'] = True
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///test.db'
db = flask.ext.sqlalchemy.SQLAlchemy(app)

class Interval(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    start = db.Column(db.Integer, nullable=False)
    end = db.Column(db.Integer, nullable=False)

    def length(self):
        return self.end - self.start

    def length(self, value):
        self.end = self.start + value

# Remove the database if it exists.
if os.path.isfile('test.db'):

with app.app_context():
    # Create the database.

    # Add an interval.
    db.session.add(Interval(id=1, start=1, end=10))

    # Make sure we can use the length setter.
    interval = Interval.query.get(1)
    interval.length = 5
    assert interval.end == 6

manager = flask.ext.restless.APIManager(app, flask_sqlalchemy_db=db)
manager.create_api(Interval, methods=['GET', 'POST', 'PUT', 'DELETE'])

The following curl command works:

curl -H "Content-Type: application/json" -d '{"start":5,"end":10}' http://localhost:5000/api/interval

The following does not work:

curl -H "Content-Type: application/json" -d '{"start":5,"length":10}' http://localhost:5000/api/interval

It returns:

  "message": "Model does not have field 'length'"


Copy link

@TimotheeJeannin TimotheeJeannin commented Oct 28, 2014

Is there anything I can do to improve those pull requests ?

It would be great to have one of them merged soon. :)


Copy link

@jfinkels jfinkels commented Oct 30, 2014

I have merged pull request #360. Thanks!


@jfinkels jfinkels closed this Oct 30, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

3 participants