Display custom error page or URLconf according to user group

Hello,

For a project I’m working on, I’m trying to create a custom error page for regular users, but I would also like the detailed yellow and grey page, we got with DEBUG = True (URLconf I think?), to be displayed for users who are part of a certain group.

I’ve been looking around but I can’t find anything on the subject, do you have any ideas?

Thank you!

Whether or not this is reasonable to do will depend upon the type of error.

If you’re dealing with a 500 error, all bets are off. You don’t want to try and rely upon the internal state of your application at that point.

You might be able to write some custom middleware that handles the exception, but I’m still not sure I’d want to rely upon having access to the ORM at that point - especially since a database error can result in that 500. See Middleware | Django documentation | Django if that’s something you’d want to try.