Sentry is built on-top of Django. It's a good example of a real-world non-trivial code base that has had to adapt as it grew up and scaled up. I haven't looked at the code in a few years, but I used to run it on-premise and found it fairly approachable and well-written, but with just the sorts of hacks you'd expect to see in a software code base that had evolved over time.
https://github.com/getsentry/sentry
Here's all the database models:
https://github.com/getsentry/sentry/tree/master/src/sentry/m...
Here's an example of hacks in the form of massive caching to improve performance:
https://github.com/getsentry/sentry/blob/master/src/sentry/d...