django-nepkit 0.1.0__py3-none-any.whl → 0.2.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. django_nepkit/__init__.py +20 -0
  2. django_nepkit/admin.py +243 -93
  3. django_nepkit/conf.py +34 -0
  4. django_nepkit/constants.py +129 -0
  5. django_nepkit/filters.py +113 -0
  6. django_nepkit/forms.py +9 -9
  7. django_nepkit/lang_utils.py +52 -0
  8. django_nepkit/models.py +138 -161
  9. django_nepkit/serializers.py +127 -28
  10. django_nepkit/static/django_nepkit/js/address-chaining.js +129 -29
  11. django_nepkit/static/django_nepkit/js/nepal-data.js +1 -0
  12. django_nepkit/static/django_nepkit/js/nepali-datepicker-init.js +55 -46
  13. django_nepkit/utils.py +270 -46
  14. django_nepkit/validators.py +1 -1
  15. django_nepkit/views.py +127 -10
  16. django_nepkit/widgets.py +100 -31
  17. django_nepkit-0.2.1.dist-info/METADATA +308 -0
  18. django_nepkit-0.2.1.dist-info/RECORD +37 -0
  19. example/demo/admin.py +45 -21
  20. example/demo/models.py +41 -4
  21. example/demo/serializers.py +39 -0
  22. example/demo/urls.py +13 -2
  23. example/demo/views.py +125 -3
  24. example/example_project/settings.py +10 -0
  25. example/example_project/urls.py +1 -1
  26. example/manage.py +2 -2
  27. django_nepkit/templatetags/__init__.py +0 -0
  28. django_nepkit/templatetags/nepali.py +0 -74
  29. django_nepkit-0.1.0.dist-info/METADATA +0 -377
  30. django_nepkit-0.1.0.dist-info/RECORD +0 -39
  31. example/demo/migrations/0001_initial.py +0 -2113
  32. example/demo/migrations/0002_alter_person_phone_number.py +0 -18
  33. example/demo/migrations/0003_person_created_at_person_updated_at.py +0 -27
  34. example/demo/migrations/0004_alter_person_created_at_alter_person_updated_at.py +0 -23
  35. example/demo/migrations/0005_alter_person_created_at_alter_person_updated_at.py +0 -27
  36. example/demo/migrations/__init__.py +0 -0
  37. {django_nepkit-0.1.0.dist-info → django_nepkit-0.2.1.dist-info}/WHEEL +0 -0
  38. {django_nepkit-0.1.0.dist-info → django_nepkit-0.2.1.dist-info}/licenses/LICENSE +0 -0
  39. {django_nepkit-0.1.0.dist-info → django_nepkit-0.2.1.dist-info}/top_level.txt +0 -0
@@ -1,377 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: django-nepkit
3
- Version: 0.1.0
4
- Summary: Django Nepali date, time, phone, and address fields with helpers.
5
- Home-page: https://github.com/S4NKALP/django-nepkit
6
- Author: Sankalp Tharu
7
- Author-email: Sankalp Tharu <sankalptharu50028@gmail.com>
8
- License: MIT
9
- Project-URL: Homepage, https://github.com/S4NKALP/django-nepkit
10
- Keywords: django,django-fields,django-forms,nepal,nepali,nepali-date,bikram-sambat,nepali-calendar,timezone,asia-kathmandu,phone-number,address,province,district,municipality
11
- Classifier: Framework :: Django
12
- Classifier: Framework :: Django :: 4.2
13
- Classifier: Framework :: Django :: 5.0
14
- Classifier: Framework :: Django :: 6.0
15
- Classifier: Programming Language :: Python :: 3
16
- Classifier: Programming Language :: Python :: 3.10
17
- Classifier: Programming Language :: Python :: 3.11
18
- Classifier: Programming Language :: Python :: 3.12
19
- Classifier: Programming Language :: Python :: 3.13
20
- Classifier: License :: OSI Approved :: MIT License
21
- Classifier: Intended Audience :: Developers
22
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
- Classifier: Topic :: Utilities
24
- Classifier: Operating System :: OS Independent
25
- Classifier: Natural Language :: English
26
- Requires-Python: >=3.11
27
- Description-Content-Type: text/markdown
28
- License-File: LICENSE
29
- Requires-Dist: django>=4.2
30
- Requires-Dist: nepali>=1.1.3
31
- Provides-Extra: drf
32
- Requires-Dist: djangorestframework>=3.14; extra == "drf"
33
- Dynamic: author
34
- Dynamic: home-page
35
- Dynamic: license-file
36
- Dynamic: requires-python
37
-
38
- # django-nepkit
39
-
40
- <div align="center">
41
-
42
- <img src="https://img.shields.io/pypi/v/django-nepkit?color=blue&label=PyPI&logo=pypi&logoColor=white" alt="PyPI">
43
- <img src="https://img.shields.io/badge/Django-4.2%E2%80%936.0-0C4B33?logo=django&logoColor=white" alt="Django 4.2–6.0">
44
- <img src="https://img.shields.io/badge/Python-3.11%2B-3776AB?logo=python&logoColor=white" alt="Python">
45
- <a href="https://github.com/S4NKALP/django-nepkit/blob/main/LICENSE"><img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License"></a>
46
-
47
- </div>
48
-
49
-
50
- `django-nepkit` is a lightweight Django utility package for Nepali projects. It provides model fields, validators, and admin helpers for:
51
-
52
- - **Bikram Sambat (BS)** date, time, and datetime
53
- - **Nepali phone number** validation
54
- - **Chained address selects** (province → district → municipality)
55
-
56
- It also includes Django admin enhancements:
57
-
58
- - `NepaliModelAdmin` automatically wires the Nepali datepicker
59
- - `NepaliDateFilter` for filtering BS dates by year
60
-
61
- Optional Django REST Framework (DRF) serializer fields are available (install with `django-nepkit[drf]`).
62
-
63
- ## Notes
64
-
65
- - The package depends on [`py-nepali`](https://github.com/opensource-nepal/py-nepali).
66
- - The date picker UI is implemented from [`sajanm/nepali-date-picker`](https://github.com/sajanm/nepali-date-picker).
67
-
68
- ---
69
-
70
- ## Table of Contents
71
-
72
- - [Installation](#installation)
73
- - [Requirements](#requirements)
74
- - [Setup](#setup)
75
- - [Quick Start](#quick-start)
76
- - [Model Fields](#model-fields)
77
- - [Address Fields (Chained Selects)](#address-fields-chained-selects)
78
- - [Django Admin](#django-admin)
79
- - [Django REST Framework](#django-rest-framework)
80
- - [Public API](#public-api)
81
- - [Contributing](#contributing)
82
- - [License](#license)
83
-
84
- ---
85
-
86
- ## Installation
87
-
88
- ```bash
89
- pip install django-nepkit
90
- ```
91
-
92
- ### Optional: DRF Serializer Fields
93
-
94
- ```bash
95
- pip install "django-nepkit[drf]"
96
- ```
97
-
98
- ---
99
-
100
- ## Requirements
101
-
102
- - Python `>=3.11`
103
- - Django `>=4.2`
104
- - `nepali>=1.1.3`
105
-
106
- ---
107
-
108
- ## Setup
109
-
110
- ### Add to `INSTALLED_APPS`
111
-
112
- ```python
113
- INSTALLED_APPS = [
114
- # ...
115
- "django.contrib.staticfiles",
116
- "django_nepkit",
117
- ]
118
- ```
119
-
120
- ---
121
-
122
- ## Quick Start
123
-
124
- ```python
125
- # models.py
126
- from django.db import models
127
- from django_nepkit import NepaliDateField, NepaliDateTimeField, NepaliPhoneNumberField
128
-
129
- class Person(models.Model):
130
- name = models.CharField(max_length=100)
131
- birth_date = NepaliDateField()
132
- created_at = NepaliDateTimeField(auto_now_add=True)
133
- phone_number = NepaliPhoneNumberField()
134
- ```
135
-
136
- ```python
137
- # admin.py
138
- from django.contrib import admin
139
- from django_nepkit import NepaliModelAdmin
140
- from .models import Person
141
-
142
- @admin.register(Person)
143
- class PersonAdmin(NepaliModelAdmin):
144
- list_display = ("name", "birth_date", "created_at", "phone_number")
145
- ```
146
-
147
- `NepaliModelAdmin` automatically loads the Nepali datepicker assets and applies the widget—no custom forms required.
148
-
149
- ---
150
-
151
- ## Model Fields
152
-
153
- ### `NepaliDateField` (BS date)
154
-
155
- Stores a BS date in the DB as a string (`YYYY-MM-DD`). In Python, it returns/accepts `nepali.datetime.nepalidate`.
156
-
157
- ```python
158
- from django_nepkit import NepaliDateField
159
-
160
- class Event(models.Model):
161
- event_date = NepaliDateField()
162
- ```
163
-
164
- **Notes:**
165
-
166
- - Stored as a string, not SQL DATE
167
- - Accepts BS strings like `"2081-10-15"`, `nepalidate`, and AD `datetime.date` (converted to BS)
168
-
169
- ---
170
-
171
- ### `NepaliDateTimeField` (BS datetime)
172
-
173
- Stores a BS datetime string (`YYYY-MM-DD HH:MM:SS`) in the DB and uses `nepalidatetime` in Python.
174
-
175
- ```python
176
- from django_nepkit import NepaliDateTimeField
177
-
178
- class Log(models.Model):
179
- created_at = NepaliDateTimeField(auto_now_add=True)
180
- updated_at = NepaliDateTimeField(auto_now=True)
181
- ```
182
-
183
- ---
184
-
185
- ### `NepaliTimeField`
186
-
187
- A normal Django `TimeField` for consistency.
188
-
189
- ```python
190
- from django_nepkit import NepaliTimeField
191
-
192
- class Shift(models.Model):
193
- start_time = NepaliTimeField()
194
- ```
195
-
196
- ---
197
-
198
- ### `NepaliPhoneNumberField`
199
-
200
- A `CharField` with Nepali phone number validation.
201
-
202
- ```python
203
- from django_nepkit import NepaliPhoneNumberField
204
-
205
- class Contact(models.Model):
206
- phone_number = NepaliPhoneNumberField()
207
- ```
208
-
209
- ---
210
-
211
- ## Address Fields (Chained Selects)
212
-
213
- Chained fields: province → district → municipality.
214
-
215
- ```python
216
- from django.db import models
217
- from django_nepkit import ProvinceField, DistrictField, MunicipalityField
218
-
219
- class Address(models.Model):
220
- province = ProvinceField()
221
- district = DistrictField()
222
- municipality = MunicipalityField()
223
- ```
224
-
225
- ### URLs required for chaining
226
-
227
- ```python
228
- # urls.py
229
- from django.urls import include, path
230
-
231
- urlpatterns = [
232
- # ...
233
- path("nepkit/", include("django_nepkit.urls")),
234
- ]
235
- ```
236
-
237
- ---
238
-
239
- ## Django Admin
240
-
241
- ### `NepaliModelAdmin`
242
-
243
- - Auto-wires datepicker for BS fields
244
- - Provides `format_nepali_date(...)` and `format_nepali_datetime(...)`
245
- - Includes `NepaliDateFilter`
246
-
247
- ```python
248
- from django.contrib import admin
249
- from django_nepkit import NepaliModelAdmin
250
-
251
- @admin.register(MyModel)
252
- class MyModelAdmin(NepaliModelAdmin):
253
- pass
254
- ```
255
-
256
- ### `NepaliDateFilter`
257
-
258
- Filter `NepaliDateField` by BS year:
259
-
260
- ```python
261
- from django_nepkit import NepaliDateFilter, NepaliModelAdmin
262
-
263
- @admin.register(MyModel)
264
- class MyModelAdmin(NepaliModelAdmin):
265
- list_filter = (("my_nepali_date_field", NepaliDateFilter),)
266
- ```
267
-
268
- **Datepicker assets used:**
269
-
270
- - JS: `https://nepalidatepicker.sajanmaharjan.com.np/v5/nepali.datepicker/js/nepali.datepicker.v5.0.6.min.js`
271
- - CSS: `https://nepalidatepicker.sajanmaharjan.com.np/v5/nepali.datepicker/css/nepali.datepicker.v5.0.6.min.css`
272
-
273
- ---
274
-
275
- ## Django REST Framework
276
-
277
- Install the extra:
278
-
279
- ```bash
280
- pip install "django-nepkit[drf]"
281
- ```
282
-
283
- ### `NepaliDateSerializerField`
284
-
285
- ```python
286
- from rest_framework import serializers
287
- from django_nepkit.serializers import NepaliDateSerializerField
288
-
289
- class PersonSerializer(serializers.Serializer):
290
- birth_date = NepaliDateSerializerField(format="%Y/%m/%d")
291
- ```
292
-
293
- ### `NepaliDateTimeSerializerField`
294
-
295
- ```python
296
- from rest_framework import serializers
297
- from django_nepkit.serializers import NepaliDateTimeSerializerField
298
-
299
- class LogSerializer(serializers.Serializer):
300
- created_at = NepaliDateTimeSerializerField()
301
- ```
302
-
303
- ---
304
-
305
- ## Public API
306
-
307
- ```python
308
- from django_nepkit import (
309
- NepaliDateField,
310
- NepaliTimeField,
311
- NepaliDateTimeField,
312
- NepaliPhoneNumberField,
313
- ProvinceField,
314
- DistrictField,
315
- MunicipalityField,
316
- NepaliDateFilter,
317
- NepaliModelAdmin,
318
- NepaliAdminMixin,
319
- )
320
- ```
321
-
322
- DRF fields live in `django_nepkit.serializers`.
323
-
324
- ---
325
-
326
- ## Contributing
327
-
328
- Contributions are welcome. If you find a bug or want an improvement, please open an issue or submit a pull request.
329
-
330
- ### Local setup
331
-
332
- Clone the repo and install dependencies (this project uses `uv`):
333
-
334
- ```bash
335
- git clone <your-fork-url>
336
- cd prod-django-nepkit
337
- uv sync
338
- ```
339
-
340
- ### Run the example project
341
-
342
- The repository contains an example Django project under `example/`.
343
-
344
- ```bash
345
- cd example
346
- uv run manage.py migrate
347
- uv run manage.py createsuperuser
348
- uv run manage.py runserver
349
- ```
350
-
351
- ### Code quality (recommended before every commit)
352
-
353
- Install and run pre-commit:
354
-
355
- ```bash
356
- uv run pre-commit install
357
- uv run pre-commit run --all-files
358
- ```
359
-
360
- You can also run Ruff directly:
361
-
362
- ```bash
363
- uv run ruff format .
364
- uv run ruff check .
365
- ```
366
-
367
- ### Pull request guidelines
368
-
369
- - Keep PRs focused and small when possible.
370
- - Update `README.md` if behavior or public API changes.
371
- - If you add a new feature, include a minimal example and tests if applicable.
372
-
373
- ---
374
-
375
- ## License
376
-
377
- MIT. See [`LICENSE`](LICENSE).
@@ -1,39 +0,0 @@
1
- django_nepkit/__init__.py,sha256=SS1Niv5hCLvv3r0-gJSrRP9AnjyP7uetJivZxc6kYPA,634
2
- django_nepkit/admin.py,sha256=EfGvOZ12slKBryjjYLYDeh5dV3ngS9LtJmr9EbarC4E,7282
3
- django_nepkit/forms.py,sha256=3FGjQK0UTWdkLByq_FvoGfcwq-NSL5nmgq4aerheDq8,1498
4
- django_nepkit/models.py,sha256=i_PBixP7o5V9lsYGAeH3_f18WTab2Mp9rgEH_NUNr_c,8991
5
- django_nepkit/serializers.py,sha256=zu-ZwaCZ0Lxv_WJpp_L4GNqAGp6ZWKWNzYGj0DcyUII,3284
6
- django_nepkit/urls.py,sha256=mPF_xEaOqNrInggBhUbwwMq-FTR7rJ0CfT0fQPx41t8,297
7
- django_nepkit/utils.py,sha256=4r-S_8_5wXvn1e8K7nmuBTnnsqpsmJlaKv3URNg25VA,2199
8
- django_nepkit/validators.py,sha256=mBIAF1M9pnoQ0zAkNyFhZb3avr_pg5YeXDfotfyLt2c,422
9
- django_nepkit/views.py,sha256=qkCNBwH5hsX3uymDRj0aH72jSdvwx9QCEEkaMP-9BmA,614
10
- django_nepkit/widgets.py,sha256=f-bUSTgB3t2VS3EBsA2qM-Vkj0T2EuOTTLYIS4PpY2Y,2468
11
- django_nepkit/static/django_nepkit/css/admin-nepali-datepicker.css,sha256=g9ago3O0UfoNwRD02AmWSdxiHmXxkQ7mpi94Nn1rO3E,834
12
- django_nepkit/static/django_nepkit/js/address-chaining.js,sha256=HRH0NxjwfDkFFbdH0ZbjCkEx4fv77gnj2s2leB0nlE0,2522
13
- django_nepkit/static/django_nepkit/js/admin-jquery-bridge.js,sha256=6iqIuSqgYssKtt61WSjye3GBpYHh3AKKYUtGL6Uh3S8,319
14
- django_nepkit/static/django_nepkit/js/nepali-datepicker-init.js,sha256=qtQrL58L-kTsyBU1LS0_3y4fCmJOzYt1e3ooFNSSadw,3909
15
- django_nepkit/templatetags/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
- django_nepkit/templatetags/nepali.py,sha256=NDapVDZ-pPCENotb4BbSYSlDJml3IIaN_QHBw8iO-B0,1754
17
- django_nepkit-0.1.0.dist-info/licenses/LICENSE,sha256=76985cvIL0AXuhZd5L2C9tbdxKMZX7IOejjvZI8kXMo,1070
18
- example/manage.py,sha256=icTnUNJM8dPiIPymP7fVQJvmGGql9e10-A-FjOwXAyM,759
19
- example/demo/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
- example/demo/admin.py,sha256=Qh-SIMjvt6ACHgrPpVjjqbLgZqkn_9z_k2xD_MblNqw,1298
21
- example/demo/apps.py,sha256=sXxYSi4dEGg-HDkM7C-TfLv26KbSUj-8HTeFS86pW8w,83
22
- example/demo/models.py,sha256=xAH5b2nVrjsqp1fR3bu4MQ_-hLbwtB8rX4TpSnnpbGE,709
23
- example/demo/tests.py,sha256=qWDvA9ZhVCQ1rPbkoFify7o_fDirXMUdYMxF12q3WIM,26
24
- example/demo/urls.py,sha256=soELX6XOYW9xacM9FUSm6URPOrVHkSpxnQU3TMhFXkw,201
25
- example/demo/views.py,sha256=cqj-6RkfGBRht35725M7IhPd-BN7y-wnd7ZecYCXLyM,799
26
- example/demo/migrations/0001_initial.py,sha256=9e2UZ-XvVk3Vba04DcgZmE9uCeB6Er9LxWtEMHhuY98,112619
27
- example/demo/migrations/0002_alter_person_phone_number.py,sha256=1UU5udaEew4LieB-_X8LsEJpQaKKzA1FGpkzgQjCA4E,424
28
- example/demo/migrations/0003_person_created_at_person_updated_at.py,sha256=N8FLAHnISLx9mm9QFK5HaCirHsjW7RfCxoVNka9-pQg,740
29
- example/demo/migrations/0004_alter_person_created_at_alter_person_updated_at.py,sha256=Mr5angejtb6pUykeVBBNB8q5pGbYMJkc3hfU27PX-4E,624
30
- example/demo/migrations/0005_alter_person_created_at_alter_person_updated_at.py,sha256=8COnCVVeJWmZZYBwdcfJBm8NP6J27khlOf764f0-ZG0,790
31
- example/demo/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
32
- example/example_project/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
33
- example/example_project/settings.py,sha256=huK0oAus70wAC9n6-wEIzu7m5Qh2-qGfT45TK2fW1l0,2027
34
- example/example_project/urls.py,sha256=vIUjmCBA6lUUhS13J0iM_hrMvP78AL7E_xZNJP0If5U,215
35
- example/example_project/wsgi.py,sha256=OK4x37NxQNVNWV4ynLqWP546tR4eALIFn7pyHc8XDNw,176
36
- django_nepkit-0.1.0.dist-info/METADATA,sha256=YtWwMo5TVCFSYrvdEwbVCe_TpSWtNZbIkuZucvgahGE,8887
37
- django_nepkit-0.1.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
38
- django_nepkit-0.1.0.dist-info/top_level.txt,sha256=Rs68WqPeyCvsWQStPNLl6vu10wCIfrFrc7xhkRcFzss,22
39
- django_nepkit-0.1.0.dist-info/RECORD,,