Skip to content

Fixes 500 errors when viewing an Organization in the Django Admin#3519

Merged
jkachel merged 3 commits intomainfrom
jkachel/fix-500s-on-org-page-django-admin
Apr 23, 2026
Merged

Fixes 500 errors when viewing an Organization in the Django Admin#3519
jkachel merged 3 commits intomainfrom
jkachel/fix-500s-on-org-page-django-admin

Conversation

@jkachel
Copy link
Copy Markdown
Contributor

@jkachel jkachel commented Apr 22, 2026

What are the relevant tickets?

n/a

Description (What does it do?)

Noticed that the Django Admin consistently returns a 500 when viewing a B2B organization in the Django Admin in production. This hopefully fixes that by prefetching the user and specifically displaying only the user email for the UserOrganizationAdminInline.

This also removes the add/change/delete permission from the inline. If you want to manage admins, you can do that from the individual user's edit screen in the Django Admin.

How can this be tested?

View an organization page in the Django Admin. It should work as expected. Ideally, use an org that has some managers set up in it. You can set that up in the user record.

Additional Context

Assuming this will help - the page takes a while to load and then errors out with a 502, but the Django process doesn't ever fail really so there's no Sentry error pointing to something specific. I can't reproduce this on RC or locally. But, the User model can be pretty unwieldy to load so this seemed like a good place to start.

@github-actions
Copy link
Copy Markdown

OpenAPI Changes

Show/hide ## Changes for v0.yaml:
## Changes for v0.yaml:
No changes detected

## Changes for v1.yaml:
No changes detected

## Changes for v2.yaml:
No changes detected

Unexpected changes? Ensure your branch is up-to-date with main (consider rebasing).

@rhysyngsun rhysyngsun self-assigned this Apr 22, 2026
Comment thread b2b/models.py Outdated

return f"UserOrganization: {self.user} in {self.organization}"

def user_email(self):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a better served with @admin.display (see the third example here), since this is very specific to django-admin.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 3ac1482

@jkachel jkachel requested a review from rhysyngsun April 23, 2026 15:25
Copy link
Copy Markdown
Collaborator

@rhysyngsun rhysyngsun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jkachel jkachel merged commit 3fc692d into main Apr 23, 2026
11 of 12 checks passed
@jkachel jkachel deleted the jkachel/fix-500s-on-org-page-django-admin branch April 23, 2026 20:51
This was referenced Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants