Skip to content

Drop unused Django contrib apps and middleware - #591

Merged
jrhoads merged 1 commit into
devfrom
quickwin/drop-django-apps
Sep 29, 2026
Merged

jrhoads merged 1 commit into
devfrom
quickwin/drop-django-apps

Conversation

@jrhoads

@jrhoads jrhoads commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

Purpose

Remove Django contrib apps and middleware that this API does not use, without changing token-authenticated JSON requests.

Approach

Edit INSTALLED_APPS and MIDDLEWARE in rorapi/settings.py only, plus the DRF defaults those removals require. Drop admin, auth, sessions, and messages, and the session, CSRF, authentication, messages, and X-Frame-Options middleware. Keep contenttypes, staticfiles, and the single CommonMiddleware entry. Set DRF authentication to an empty list and UNAUTHENTICATED_USER / UNAUTHENTICATED_TOKEN to None, because the framework defaults import django.contrib.auth.

Key Modifications

  • Remove django.contrib.admin, auth, sessions, and messages from INSTALLED_APPS.
  • Remove SessionMiddleware, CsrfViewMiddleware, AuthenticationMiddleware, MessageMiddleware, and XFrameOptionsMiddleware.
  • Set DEFAULT_AUTHENTICATION_CLASSES to [] and the unauthenticated user and token to None.

Important Technical Details

  • Write access still uses OurTokenPermission and the Route-User / TOKEN headers. It does not use Django users or sessions.
  • AnonRateThrottle on client registration still throttles requests with no authenticated user, which is every request under these DRF defaults.
  • CommonMiddleware stays. contenttypes and staticfiles stay.
  • Responses no longer include X-Frame-Options. This API returns JSON and does not render browser pages.
  • Template context processors for auth and messages are unchanged. Nothing in the request path renders those templates.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Test plan

  • CI tests_unit on this PR
  • manage.py check and makemigrations --check succeed

Reviewer, please remember our guidelines:

  • Be humble in the language and feedback you give, ask don't tell.
  • Consider using positive language as opposed to neutral when offering feedback. This is to avoid the negative bias that can occur with neutral language appearing negative.
  • Offer suggestions on how to improve code e.g. simplification or expanding clarity.
  • Ensure you give reasons for the changes you are proposing.
Open in Web Open in Cursor 

The API does not use admin, auth, sessions, or messages. Clear DRF's default session authentication so requests do not import django.contrib.auth.

Co-authored-by: Joseph Rhoads <jrhoads@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The focused configuration changes are consistent with existing API authorization and throttling behavior.

Review effort: Balanced
Findings: None

@jrhoads
jrhoads merged commit bef5d03 into dev Sep 29, 2026
4 of 5 checks passed
@jrhoads
jrhoads deleted the quickwin/drop-django-apps branch September 29, 2026 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants