princekhunt / privateping

PrivatePing is a secure messaging application built on Python's Django framework, providing end-to-end encryption for messages exchanged between users.
https://privateping.bytespot.tech
MIT License
125 stars 30 forks source link

Refactor Path Handling in Settings Using `pathlib.Path` #54

Closed snipher-marube closed 4 days ago

snipher-marube commented 5 days ago

Summary:

This pull request refactors the path handling in the Django project's settings files by using pathlib.Path instead of os.path. These changes improve readability, maintainability, and cross-platform compatibility of the settings configuration.

Changes Made:

  1. Updated BASE_DIR Calculation:
  1. Updated BASE_DIR Calculation:
  1. Production Settings:

Detailed Changes: Updated BASE_DIR Calculation:

from pathlib import Path

BASE_DIR = Path(__file__).resolve().parent.parent

Development Settings (development.py):

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR / 'db.sqlite3',
    }
}

STATICFILES_DIRS = [
    BASE_DIR / '../assets/static'
]

Production Settings (production.py):

STATICFILES_DIRS = [
    BASE_DIR / '../assets/static'
]

STATIC_ROOT = BASE_DIR / '../assets/'

Testing:

Additional Notes:

Thank you for reviewing this pull request!