diff --git a/tailbone/forms2/core.py b/tailbone/forms2/core.py index f3a3cae7..d3301bdf 100644 --- a/tailbone/forms2/core.py +++ b/tailbone/forms2/core.py @@ -145,10 +145,20 @@ class CustomSchemaNode(SQLAlchemySchemaNode): msg = 'excludes and includes are mutually exclusive.' raise ValueError(msg) - properties = sorted(self.inspector.attrs, key=_creation_order) # sorted to maintain the order in which the attributes # are defined - for name in includes or [item.key for item in properties]: + properties = sorted(self.inspector.attrs, key=_creation_order) + if excludes: + if includes: + raise ValueError("Must pass includes *or* excludes, but not both") + supported = [prop.key for prop in properties + if prop.key not in excludes] + elif includes: + supported = includes + elif includes is not None: + supported = [] + + for name in supported: prop = self.inspector.attrs.get(name, name) if name in excludes or (includes and name not in includes):