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:
sankalp committed 2026-01-30 15:22:13 +05:45
1 parent 7b07835e0c
commit 09f302ceaa
18 files changed
+2644 -164

No files matched your search

+12 -5
View File
@@ -5,21 +5,28 @@ from typing import Any, Optional
from nepali.datetime import nepalidate, nepalidatetime
from nepali.locations import districts, provinces
from django_nepkit.conf import nepkit_settings
BS_DATE_FORMAT = "%Y-%m-%d"
BS_DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S"
def _try_parse_nepali(value: Any, cls: Any, fmt: str) -> Any:
def _try_parse_nepali(value: Any, cls: Any, fallback_fmt: str) -> Any:
"""Internal helper to parse Nepali date/datetime."""
if value in (None, ""):
return None
if isinstance(value, cls):
return value
if isinstance(value, str):
try:
return cls.strptime(value.strip(), fmt)
except Exception:
return None
formats = nepkit_settings.DATE_INPUT_FORMATS
if fallback_fmt not in formats:
formats = list(formats) + [fallback_fmt]
for fmt in formats:
try:
return cls.strptime(value.strip(), fmt)
except Exception:
continue
return None