feat: implement zero-config address chaining and revamp documentation

This commit is contained in:
sankalp committed 2026-01-30 14:32:15 +05:45
1 parent b127d925f1
commit 7b07835e0c
7 files changed
+154 -74

No files matched your search

+16 -3
View File
@@ -42,7 +42,10 @@ class NepaliWidgetMixin:
class ChainedSelectWidget(forms.Select):
class Media:
js = ("django_nepkit/js/address-chaining.js",)
js = (
"django_nepkit/js/nepal-data.js",
"django_nepkit/js/address-chaining.js",
)
class ProvinceSelectWidget(NepaliWidgetMixin, ChainedSelectWidget):
@@ -53,13 +56,23 @@ class ProvinceSelectWidget(NepaliWidgetMixin, ChainedSelectWidget):
class DistrictSelectWidget(NepaliWidgetMixin, ChainedSelectWidget):
def _configure_attrs(self, attrs):
_append_css_class(attrs, "nepkit-district-select")
attrs["data-url"] = reverse_lazy("django_nepkit:district-list")
try:
url = reverse_lazy("django_nepkit:district-list")
str(url) # Force evaluation to catch NoReverseMatch
attrs["data-url"] = url
except Exception:
pass
class MunicipalitySelectWidget(NepaliWidgetMixin, ChainedSelectWidget):
def _configure_attrs(self, attrs):
_append_css_class(attrs, "nepkit-municipality-select")
attrs["data-url"] = reverse_lazy("django_nepkit:municipality-list")
try:
url = reverse_lazy("django_nepkit:municipality-list")
str(url) # Force evaluation to catch NoReverseMatch
attrs["data-url"] = url
except Exception:
pass
class NepaliDatePickerWidget(NepaliWidgetMixin, forms.TextInput):