feat: implement address normalization and demo
- Add utility to parse raw address strings into structured Province, District, and Municipality data. - Support both English and Nepali (Devanagari) inputs with smart matching for character variations. - Implement comprehensive test suite for address normalization logic. - Add real-time address normalization demo to the example app using HTMX. - Update README with documentation and usage examples for the new utility.
This commit is contained in:
11 files changed
+322
-33
No files matched your search
+17
-2
@@ -11,11 +11,10 @@ from .serializers import (
|
||||
TransactionSerializer,
|
||||
)
|
||||
from django_nepkit.filters import (
|
||||
NepaliDateYearFilter,
|
||||
NepaliDateMonthFilter,
|
||||
NepaliCurrencyRangeFilter,
|
||||
NepaliDateRangeFilter,
|
||||
)
|
||||
from django_nepkit.utils import normalize_address
|
||||
|
||||
|
||||
class PersonForm(forms.ModelForm):
|
||||
@@ -137,3 +136,19 @@ class TransactionViewSet(viewsets.ModelViewSet):
|
||||
fields = ["title", "amount", "date"]
|
||||
|
||||
filterset_class = TransactionFilter
|
||||
|
||||
|
||||
def address_normalize_demo(request):
|
||||
address = request.GET.get("address", "")
|
||||
result = None
|
||||
if address:
|
||||
result = normalize_address(address)
|
||||
|
||||
if request.headers.get("HX-Request") == "true":
|
||||
return render(
|
||||
request, "demo/address_normalize_partial.html", {"result": result}
|
||||
)
|
||||
|
||||
return render(
|
||||
request, "demo/address_normalize.html", {"address": address, "result": result}
|
||||
)
|
||||
Reference in new issue
Block a user