feat: implement HTMX support, DRF filters, and professionalized documentation
- Implement server-side location chaining with HTMX support via `htmx=True` in fields and widgets. - Update location views to handle HTMX requests and return HTML <option> fragments. - Add NepaliDateYearFilter and NepaliDateRangeFilter for robust DRF API filtering. - Expand default `DATE_INPUT_FORMATS` in configuration to support multiple common Nepali date styles. - Update DRF serializers to automatically respect global `NEPKIT` configuration settings. - Add `django-filter` as an optional dependency under the `drf` extra in pyproject.toml. - Correct underlying dependency references from `nepali-datetime` to nepali library. - Complete overhaul of README.md for premium DX, including new sections for storage behavior, timezone awareness, and API usage.
This commit is contained in:
18 files changed
+2644
-164
No files matched your search
@@ -0,0 +1,34 @@
|
||||
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,
|
||||
}
|
||||
|
||||
|
||||
class NepkitSettings:
|
||||
"""
|
||||
A settings object that allows items to be accessed as properties.
|
||||
"""
|
||||
|
||||
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 for user setting
|
||||
val = self._user_settings[attr]
|
||||
except KeyError:
|
||||
# Fall back to defaults
|
||||
val = self.defaults[attr]
|
||||
|
||||
return val
|
||||
|
||||
|
||||
nepkit_settings = NepkitSettings(getattr(settings, "NEPKIT", {}), DEFAULTS)
|
||||
Reference in new issue
Block a user