Skip to content

Fix local development setup with django-ninja 0.22.x, Docker Postgres, and Swagger static assets#126

Open
ayu-yishu13 wants to merge 6 commits intom2b3:testfrom
ayu-yishu13:test
Open

Fix local development setup with django-ninja 0.22.x, Docker Postgres, and Swagger static assets#126
ayu-yishu13 wants to merge 6 commits intom2b3:testfrom
ayu-yishu13:test

Conversation

@ayu-yishu13
Copy link

@ayu-yishu13 ayu-yishu13 commented Feb 10, 2026

Fixes: #125

This PR fixes multiple local development issues that surfaced after aligning Django-ninja with the version currently compatible with the existing codebase.
->The changes were made after discussion confirming that the code should remain unchanged and the dependency version should be pinned to Django-ninja 0.22.x.

Issues Addressed:-

  1. Dependency incompatibility (Django-ninja 1.x)

    • Django-ninja 1.x introduced breaking changes (notably around ModelSchema / Config)
    • Per maintainer guidance, the fix is pinning the version instead of modifying existing API schemas
      -pyproject.toml updated to pin Django-ninja to 0.22.x
  2. File upload parameter compatibility
    -After pinning Django-ninja to 0.22.x, endpoints using UploadedFile = File(None) required adjustment
    -Updated API files to ensure compatibility:
    -users/api.py
    -articles/api.py
    -communities/api.py

  3. Docker local development missing PostgreSQL service
    -docker-compose.dev.yml did not include a Postgres service, causing DB connection failures in local setup
    -Added a Postgres service aligned with existing environment variable configuration
    -Updated service dependencies accordingly

  4. Swagger UI static assets not loading
    -Swagger UI was loading HTML responses instead of CSS/JS (MIME type error)
    -Fixed by:
    Correcting static file configuration
    Enabling WhiteNoise static handling
    Removing incompatible Ninja middleware
    Swagger UI now loads correctly

What Was Changed:-

1)pyproject.toml
→ Pin Django-ninja to 0.22.x

2)docker-compose.dev.yml
→ Add PostgreSQL service for local development

3)users/api.py, articles/api.py, communities/api.py
→ Fix file upload parameter definitions for compatibility

4)myapp/settings.py
→ Static files & middleware adjustments for Swagger UI
Swagger
DockerImg

@ayu-yishu13
Copy link
Author

@bsureshkrishna
Sir are u implying that we should focus on frontend for now and try to fix that as u commented 1 hour back and changing backend will have less effect because for now backend is running fine?
Please correct me if I am wrong.

@bsureshkrishna
Copy link

Please discuss this on SciCommons; the issues to focus on etc. are being discussed there. Yes, since the backend is working stably for us for now, bringing the official repo up to date is medium priority.

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.

2 participants