Skip to content

Modernize: Django 1.4 → Django 5.2 LTS clean cutover#5

Draft
yuguang wants to merge 9 commits into
masterfrom
modernize/django5
Draft

Modernize: Django 1.4 → Django 5.2 LTS clean cutover#5
yuguang wants to merge 9 commits into
masterfrom
modernize/django5

Conversation

@yuguang

@yuguang yuguang commented Jun 13, 2026

Copy link
Copy Markdown
Owner

Summary

Clean cutover from Django 1.4.16 (2012) to Django 5.2.15 LTS on Python 3.14. All dead dependencies replaced. All smoke tests passing.

What Changed

Phase Change
Scaffolding New Django 5.2 project skeleton; cloud_ide patched for Python 3 compat (7 files)
Models + Data Export/import scripts for legacy DB cutover (scripts/)
Auth django-social-authsocial-auth-app-django (Google/Twitter/Facebook OAuth2)
Static django-mediasync → Whitenoise; 192 static files managed
Fiddle Engine All 6 URL patterns wired; views/models/forms smoke-tested
Templates Dead {% load mediasync %} / {% load chunks %} replaced; stub tag libraries added
Validation All automated checks passing (HTTP 200, URL reversal, CRUD, i18n, collectstatic)

Removed Dependencies

  • django-mediasync (dead)
  • django-social-auth (dead)
  • django-chunks (dead)

Added Dependencies

  • Django>=5.2
  • social-auth-core + social-auth-app-django
  • whitenoise
  • django-taggit (kept, updated)

Smoke Test Results

manage.py check     → 0 issues
manage.py migrate   → no migrations to apply
GET /               → HTTP 200
GET /login/         → HTTP 200
URL reversal        → 8/8 PASSED
Snippet CRUD        → PASSED
i18n (en + zh)      → PASSED
collectstatic       → 0 errors, 192 files

Cutover Instructions

See docs/modernization/VALIDATION_CHECKLIST.md for the full data export/import runbook.

Before Merging

  • Set OAuth credentials as env vars (GOOGLE_KEY, GOOGLE_SECRET, TWITTER_KEY, etc.)
  • Manual browser test: fiddle editor, run button, save/open, language switch
  • Configure production WSGI server (gunicorn/uvicorn)

Planned and implemented with Oz | Plan

Co-Authored-By: Oz oz-agent@warp.dev

yuguang and others added 9 commits June 13, 2026 16:19
- Replace Django 1.4 manage.py with Django 5.2 version
- Add pythonfiddle_modern/ project package with settings, urls, wsgi, asgi
- Configure settings.py: whitenoise, social_django, taggit, cloud_ide.fiddle,
  auth backends, i18n (en/zh), LocaleMiddleware, ALLOWED_HOSTS=['*'] for dev
- Update requirements.txt: Django>=5.2, social-auth-core, social-auth-app-django,
  django-taggit, whitenoise (replaces mediasync + django-social-auth)
- Add .gitignore (excludes .venv, __pycache__, *.pyc, db.sqlite3)
- Add docs/modernization/ with PORTED_MODELS.md, DATA_MIGRATION.md,
  VALIDATION_CHECKLIST.md, old_inspectdb.txt
- Add COMPLETION.md with bootstrap commands and handoff notes

Python 2 / Django 1.4 patches applied to cloud_ide (editable install):
  compression.py, models.py, forms.py, admin.py, views.py,
  jsonresponse.py, templatetags/jqtmpl.py

Exit criteria passed:
  - python manage.py migrate: OK (fiddle.0001_initial applied)
  - python manage.py runserver 8001: starts without ImportError on Django 5.2.15

Co-Authored-By: Oz <oz-agent@warp.dev>
- Add STATICFILES_DIRS pointing to project-level static/ directory
- Create static/favicon.ico placeholder (16x16 transparent ICO)
- STATIC_ROOT, Whitenoise CompressedManifestStaticFilesStorage, and
  staticfiles/ .gitignore entry were already set by Phase 0
- collectstatic: 128 files copied, 384 post-processed, 0 errors
- manage.py check: 0 issues

Co-Authored-By: Oz <oz-agent@warp.dev>
Co-Authored-By: Oz <oz-agent@warp.dev>
- scripts/export_legacy_data.py: reads legacy SQLite DB directly (no Django
  required), dumps Language/Snippet/taggit tables to JSON, decompresses
  CompressedTextField blobs (gzip → zlib → UTF-8 fallback chain)
- scripts/import_legacy_data.py: reads JSON export, get_or_create Language,
  create Snippet with username-based author lookup (fallback: legacy_import_user),
  re-applies tags via snippet.tags.set(); logs and counts skipped rows
- scripts/README.md: full usage docs including full roundtrip example
- docs/modernization/DATA_MIGRATION.md: filled in with actual commands,
  column-level schema mapping, roundtrip test results, and open issues
- .gitignore: exclude legacy_export.json (generated artefact)

Roundtrip test passed: 1 Language + 1 Snippet (with 2 tags) exported from
db.sqlite3 and re-imported cleanly (0 skipped rows).

Co-Authored-By: Oz <oz-agent@warp.dev>
Co-Authored-By: Oz <oz-agent@warp.dev>
- Add social_django.urls at /social-auth/ with namespace='social'
- Add TemplateView placeholder at /login/ (Phase 5 supplies real template)
- Add LogoutView at /logout/ (POST-only, Django 5 CSRF-safe)
- SOCIAL_AUTH_URL_NAMESPACE, env-var OAuth keys, and social_django
  INSTALLED_APPS / AUTHENTICATION_BACKENDS were already set in settings.py
- Document cloud_ide.login as superseded: it uses django-social-auth
  (removed package), Django 1.4 URL patterns, and render_to_response;
  do not add to INSTALLED_APPS
- All social backend URL reverses verified working
- manage.py check: 0 issues

Co-Authored-By: Oz <oz-agent@warp.dev>
- Verified cloud_ide.fiddle URL wiring (6 fiddle patterns + i18n)
- Confirmed manage.py check passes (0 issues)
- Smoke tested views/models/forms imports
- Validated Snippet CRUD + CompressedTextField round-trip
- Verified URL reverse/resolve for all patterns
- Confirmed tag_hint taggit annotate query works

Note: cloud_ide/fiddle/urls.py was pre-committed by Phase 0;
pythonfiddle_modern/urls.py fiddle include was added by Phase 2.

Co-Authored-By: Oz <oz-agent@warp.dev>
- Remove dead mediasync/chunks template tag loads from all templates
- Replace {% css %} with {% static %}, {% media_url %} with {% get_static_prefix %}
- Remove {% chunk %} tags (django-chunks removed)
- All smoke tests passing: HTTP 200 on /, /login/; URL reversal, CRUD, i18n, collectstatic
- VALIDATION_CHECKLIST.md written with cutover runbook
- static/css/, static/images/, static/js/: full set of frontend assets
- pythonfiddle_modern/templatetags/chunks.py + mediasync.py: no-op stub
  template tag libraries replacing dead django-chunks and django-mediasync
  packages, allowing templates to load without errors
- pythonfiddle_modern/settings.py: env-driven CLOUD_IDE_TEMPLATES_DIR and
  DJANGO_DB_PATH, flatpages in INSTALLED_APPS, correct TEMPLATES DIRS order
- run.sh, fetch_static.sh, setup-virtualenv.sh: dev helper scripts
- .gitignore: exclude extra venvs and macOS-specific scripts

Co-Authored-By: Oz <oz-agent@warp.dev>
@yuguang yuguang changed the title feat: scaffold Django 5.2 project skeleton (Phase 0) Modernize: Django 1.4 → Django 5.2 LTS clean cutover Jul 3, 2026
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.

1 participant