Rethink of the 500 page when user has not run makemigrations+migrate

The 500 page when the user hasn’t run makemigrations+migrate is quite intimidating, and there’s a constant stream of questions about this on discord, reddit, and this forum. I suspect there’s a few people who we never hear from what just give up on Django at this point too.

I suggest this error message (and a button to do the right thing):

The database schema is out of sync with the model definitions.

Would you like to create migrations and apply them now?

[Yes, run makemigrations + migrate]

Remember to commit your migration files to source control.

Raw error follows:

<current error page>
1 Like

How are you going to determine if makemigrations is missing? Simply assume that this is the case for every database error that occurs?

Yea that’s my thinking. A big button that does both. If the makemigrations command produces questions, tell the user to run it from the command line. Start small.

I honestly don’t see this happening without a smarter logic. A unique constraint violation etc is usually not fixed by makemigrations. Checking the error codes for missing tables/columns or invalid types is probably hard over all databases involved.

Hmm… I wonder how fast it is to run a dry run of makemigrations and see if there’s anything there? That’d do it.

In any case, the implementation isn’t really the point I think. The point is to imagine a better future and when you can see the goal clearly, THEN try to figure out the technical details. That’s the first step I’m aiming for here. More of a vision than a PR.