Skip to content

AttributeError using model_form on models using Joined Table Inheritance #46

Open
@mfisher87

Description

@mfisher87

When I'm using Joined Table Inheritance by specifying __mapper_args__ in my model, I get the following error calling model_form() on my model:

AttributeError: Neither 'Label' object nor 'Comparator' object has an attribute 'nullable'

I can get around this by making the following change to model_fields():

      field_args = field_args or {}
      properties = []

      for prop in mapper.attrs.values():
+         if getattr(prop, "_is_polymorphic_discriminator", False):
+             continue
          if getattr(prop, "columns", None):
              if exclude_fk and prop.columns[0].foreign_keys:
                  continue

I don't have deep enough knowledge of sqlalchemy to know if there is a better field I should be checking. If this looks right, I'm happy to open a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions