Files
django-nepkit/django_nepkit/conf.py
T
sankalp 1338f9e5fe refactor: global project refinement, DRY consolidation, and documentation overhaul
This commit represents a comprehensive improvement of the library's architecture, developer experience, and documentation accuracy.

Core Refactoring:
- apply DRY principle to models.py by introducing BaseNepaliBSField and BaseLocationField
- standardize widget logic in widgets.py using NepaliWidgetMixin
- centralize admin filtering logic into BaseNepaliDateFilter

New Features & API:
- add NepaliMonthFilter for Django Admin and NepaliDateMonthFilter for DRF
- implementation of HTMX-driven location chaining for dynamic address selects
- extend demo project with comprehensive DRF search, ordering, and filter examples

Configuration & Sync:
- implement global NEPKIT settings in conf.py (DEFAULT_LANGUAGE, ADMIN_DATEPICKER, etc.)
- universalize BS_DATE_FORMAT/BS_DATETIME_FORMAT across the entire stack
- synchronize frontend datepicker initialization with backend date formats

Documentation & DX:
- complete rewrite of README.md into high-energy, factual, English-only guides
- project-wide audit and simplification of comments/docstrings for beginner accessibility
- expanded 'Technical Design' and 'FAQ' sections covering data integrity and storage
- added docs/migration_guide.py for bulk AD-to-BS data transitions

Quality & Maintenance:
- fixed all E402 module-level import errors across the library
- verified codebase with project-wide ruff checks (all checks passed)
2026-01-30 17:00:33 +05:45

35 lines
981 B
Python

from django.conf import settings
DEFAULTS = {
"DEFAULT_LANGUAGE": "en",
"DATE_INPUT_FORMATS": ["%Y-%m-%d", "%d/%m/%Y", "%d-%m-%Y"],
"ADMIN_DATEPICKER": True,
"TIME_FORMAT": 12,
"BS_DATE_FORMAT": "%Y-%m-%d",
"BS_DATETIME_FORMAT": "%Y-%m-%d %H:%M:%S",
}
class NepkitSettings:
"""Handles the global NEPKIT settings from your settings.py."""
def __init__(self, user_settings=None, defaults=None):
self._user_settings = user_settings or {}
self.defaults = defaults or DEFAULTS
def __getattr__(self, attr):
if attr not in self.defaults:
raise AttributeError(f"Invalid NEPKIT setting: '{attr}'")
try:
# Check if the user has a custom setting
val = self._user_settings[attr]
except KeyError:
# Use default value if not set
val = self.defaults[attr]
return val
nepkit_settings = NepkitSettings(getattr(settings, "NEPKIT", {}), DEFAULTS)