Files
django-nepkit/example/demo/models.py
T
sankalp 09f302ceaa 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.
2026-01-30 15:22:13 +05:45

34 lines
1.3 KiB
Python

from django.db import models
from django_nepkit import (
NepaliDateField,
NepaliTimeField,
NepaliPhoneNumberField,
NepaliDateTimeField,
ProvinceField,
DistrictField,
MunicipalityField,
)
class Person(models.Model):
name = models.CharField(max_length=100)
# Date/time fields - now default to English via NEPKIT['DEFAULT_LANGUAGE']
birth_date = NepaliDateField() # Defaults to en=True
birth_date_ne = NepaliDateField(ne=True, blank=True, null=True) # Explicitly Nepali
registration_time = NepaliTimeField(auto_now_add=True) # Defaults to en=True
phone_number = NepaliPhoneNumberField()
# Address chaining - now default to English via NEPKIT['DEFAULT_LANGUAGE']
province = ProvinceField() # Defaults to en=True
province_ne = ProvinceField(ne=True, blank=True, null=True) # Explicitly Nepali
district = DistrictField() # Defaults to en=True
district_ne = DistrictField(ne=True, blank=True, null=True) # Explicitly Nepali
municipality = MunicipalityField() # Defaults to en=True
municipality_ne = MunicipalityField(ne=True, blank=True, null=True) # Explicitly Nepali
created_at = NepaliDateTimeField(auto_now_add=True) # Defaults to en=True
updated_at = NepaliDateTimeField(auto_now=True) # Defaults to en=True
def __str__(self):
return self.name