I understand your frustration with the data loss caused by deprecated settings during your Django upgrade. This is indeed a challenging issue that highlights an important aspect of Django's upgrade process.
Addressing Deprecation Warnings
Django's approach to deprecation warnings has evolved over time. Since Django 1.11, deprecation warnings are no longer displayed by default, which aligns with Python's default behavior. This means you need to explicitly enable these warnings to catch potential issues before upgrading.
Enabling Deprecation Warnings
To catch these issues before they cause problems, you should enable deprecation warnings during your testing phase:
# Using Django's test runner
python -Wa manage.py test
# Using pytest
PYTHONWARNINGS=always pytest tests --capture=no
This would help identify deprecated settings before they cause silent failures in production.
Potential Solutions
Your suggestion about having system checks for outdated/invalid settings is valuable. Django's deprecation policy ensures features are deprecated over at least two feature releases before removal, but detecting when settings are no longer valid could be improved.
Some approaches that might help:
- Pre-upgrade Testing: Run your application with warnings enabled in a staging environment before upgrading in production
- Integration Tests: As you mentioned, having integration tests specifically for storage functionality would catch these issues
- Upgrade Checklist: Following a comprehensive checklist when upgrading Django versions
Django's Deprecation Policy
Django's current policy is to:
- Deprecate features in version A.x with warnings
- Maintain backward compatibility in all A.x versions
- Remove deprecated features in version B.0 or B.1
This gives developers time to adapt, but requires actively checking for deprecation warnings.
Your experience highlights a gap in the current process, especially for settings that might silently fail when deprecated. A system check for deprecated settings would indeed be a valuable addition to Django's upgrade tooling.