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

dump_only ignored for relationship fields #25

sssilver opened this issue Sep 7, 2015 · 3 comments


Copy link

commented Sep 7, 2015

After declaring a relationship field as dump_only, the data is still loaded back into the object.

Model and schema:

class Course(rod.model.db.Model):
    __tablename__ = 'course'

    id = sqlalchemy.schema.Column(sqlalchemy.types.Integer, primary_key=True)
    title = sqlalchemy.schema.Column(sqlalchemy.types.String())

    # Levels of this course
    levels = sqlalchemy.orm.relationship(

class CourseSchema(rod.model.BaseSchema):
    class Meta(rod.model.BaseSchema.Meta):
        model = rod.model.course.Course

    levels = marshmallow_sqlalchemy.field_for(rod.model.course.Course, 'levels', dump_only=True)

Loading the object:

data = {
    'title': 'Test Course',
    'levels': [1, 2, 3]  # Should be ignored
course = CourseSchema().load(data).data

print course.levels




{InstrumentedList} [<Level object>, <Level object>, <Level object>]

@sloria sloria added the bug label Sep 11, 2015


This comment has been minimized.

Copy link

commented Sep 11, 2015

Good catch. I will look into this this weekend. Thanks for reporting.


This comment has been minimized.

Copy link

commented Sep 11, 2015

Thanks for responding! This is blocking me, so I'll be keeping an eye for an update :)

@sloria sloria closed this in 9ca555e Sep 14, 2015


This comment has been minimized.

Copy link

commented Sep 14, 2015

The fix is now in the latest PyPI release (0.4.1).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.