Skip to content

Support for custom model class #135

Closed

Description

@stecik

What problem does this solve?

In my project i use custom class that inherites from model.Model but is not detected by orm-lens

class MyCustomModel(models.Model):
...
class Person(MyCustomModel):
...

Proposed solution

Add user configuration or even better autodetect inheritance from model.Model

Alternatives you considered

No response

Activity

  1. FROWNINGdev commented on Oct 8, 2026

    @FROWNINGdev
    Owner

    Thanks for the report, @stecik. Fixed in #136 and merged to main. It will go out in the next release of both the extension and the CLI.

    There was nothing wrong with the inheritance itself. The scan only reads models.py, abstract_models.py and models/*.py, so a base living in, say, core/base.py had no definition to resolve against, and everything below it got dropped. The scan now follows your model's imports to the file that defines the base, so no configuration is needed. That covers:

    • from core.base import MyCustomModel and relative from .base import MyCustomModel
    • module aliases, such as from core import base → class Person(base.MyCustomModel)
    • re-exports through a package __init__.py
    • chains, where your base inherits from another base in yet another file

    Fields from an abstract base show up as inherited fields on Person, the same as when the base sits in models.py.

    One limit: the base has to live inside the workspace. If yours comes from an installed package rather than your own code, please say so here and I'll look at a setting for that case.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions