Skip to content

Conversation

@RajdeepKushwaha5
Copy link

Overview

This PR addresses deprecation warnings in the Django application and performs minor code cleanup to improve maintainability and future compatibility.


Changes Made

1. Fixed pythonjsonlogger Import Deprecation

File: settings.py

  • Change: Updated the logging formatter import from
    "pythonjsonlogger.jsonlogger.JsonFormatter""pythonjsonlogger.json.JsonFormatter"
  • Reason: The jsonlogger module has been moved to json in newer versions of python-json-logger, causing deprecation warnings.
  • Impact: Eliminates deprecation warning in logs without affecting functionality.

2. Fixed Django 6.0 URLField Deprecation Warning

File: settings.py

  • Change: Added FORMS_URLFIELD_ASSUME_HTTPS = True setting
  • Reason: Django 6.0 will change the default scheme for URLField from 'http' to 'https'.
    This setting silences the warning and opts into the new behavior.
  • Impact: Prevents warnings in tests and forms, ensuring compatibility with future Django versions.

3. Removed Unused Imports

Files:

  • settings.py: Removed from django.templatetags.static import static

  • homework.py: Removed from courses.validators.validating_json_field import ValidatingJSONField

  • Reason: These imports were not used in the code, leading to linting warnings and potential confusion.

  • Impact: Cleaner code, reduced import overhead, no functional changes.


Testing

  • Test Suite: All 178 tests pass successfully
  • Coverage: No regressions in existing functionality
  • Warnings: Reduced deprecation warnings (pythonjsonlogger warning eliminated)
  • Manual Testing: Verified that the application starts and core features work as expected

Impact Assessment

Area Impact
Breaking Changes None
Performance No impact
Security No impact
User Experience No impact
Database No migrations required

Motivation

These changes improve code quality and prepare the codebase for Django 6.0 by addressing deprecation warnings that would become errors in future versions.
The cleanup also enhances maintainability by removing unused code.


Checklist

  • Tests pass
  • No breaking changes
  • Code follows project style guidelines
  • Documentation updated (not applicable)
  • Reviewed for security implications
- Update pythonjsonlogger import to new path - Add FORMS_URLFIELD_ASSUME_HTTPS setting for Django 6.0 compatibility - Remove unused imports in settings.py and homework.py - Minor formatting improvements in model files
@alexeygrigorev
Copy link
Member

Can you remove formatting edits? it's hard to understand which changes are important and which are just formatting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants