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

AttributeError using model_form on models using Joined Table Inheritance #46

Open
mfisher87 opened this issue Mar 13, 2024 · 0 comments

Comments

@mfisher87
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant