The developer of orm-lens, a static analyzer for Django models and migrations, tested the tool against 24 open-source projects, including NetBox, PostHog, and Zulip. The analysis revealed that real-world Django code often deviates from standard tutorial patterns, leading to parsing errors in the tool.
Common issues identified included complex class inheritance, dynamic model loading via get_model, and non-standard migration file naming conventions. For instance, the tool initially failed to identify models in Tandoor due to custom mixins and miscounted arguments in Mayan EDMS migrations.
The project now incorporates a testing suite based on these real-world codebases to ensure accuracy. Since November 9, the community has contributed 58 merged pull requests to address these edge cases. Two issues, specifically regarding custom field classes and duplicate folder names, remain open for contributors.
The orm-lens tool is available under an MIT license. It provides functionality to list models, check for drifts between models and migration history, and assess migration risks. Users are encouraged to report errors via GitHub issues to help improve the analyzer's compatibility with diverse Django implementations.






