Most sufficiently complex codebases that aren’t “framework” based will have a poorly implemented, feature-lacking, bug-ridden version of a framework eventually.
If Django doesn’t fit the use case for your thing, don’t use it? Just don’t use flask and then start reimplementing Django.
Also, Rails is better Django. It’s not even a close comparison.