django-nepkit 0.1.0__tar.gz

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 (46) hide show
  1. django_nepkit-0.1.0/LICENSE +21 -0
  2. django_nepkit-0.1.0/MANIFEST.in +3 -0
  3. django_nepkit-0.1.0/PKG-INFO +377 -0
  4. django_nepkit-0.1.0/README.md +340 -0
  5. django_nepkit-0.1.0/django_nepkit/__init__.py +31 -0
  6. django_nepkit-0.1.0/django_nepkit/admin.py +211 -0
  7. django_nepkit-0.1.0/django_nepkit/forms.py +50 -0
  8. django_nepkit-0.1.0/django_nepkit/models.py +269 -0
  9. django_nepkit-0.1.0/django_nepkit/serializers.py +113 -0
  10. django_nepkit-0.1.0/django_nepkit/static/django_nepkit/css/admin-nepali-datepicker.css +37 -0
  11. django_nepkit-0.1.0/django_nepkit/static/django_nepkit/js/address-chaining.js +64 -0
  12. django_nepkit-0.1.0/django_nepkit/static/django_nepkit/js/admin-jquery-bridge.js +10 -0
  13. django_nepkit-0.1.0/django_nepkit/static/django_nepkit/js/nepali-datepicker-init.js +108 -0
  14. django_nepkit-0.1.0/django_nepkit/templatetags/__init__.py +0 -0
  15. django_nepkit-0.1.0/django_nepkit/templatetags/nepali.py +74 -0
  16. django_nepkit-0.1.0/django_nepkit/urls.py +10 -0
  17. django_nepkit-0.1.0/django_nepkit/utils.py +77 -0
  18. django_nepkit-0.1.0/django_nepkit/validators.py +12 -0
  19. django_nepkit-0.1.0/django_nepkit/views.py +22 -0
  20. django_nepkit-0.1.0/django_nepkit/widgets.py +72 -0
  21. django_nepkit-0.1.0/django_nepkit.egg-info/PKG-INFO +377 -0
  22. django_nepkit-0.1.0/django_nepkit.egg-info/SOURCES.txt +44 -0
  23. django_nepkit-0.1.0/django_nepkit.egg-info/dependency_links.txt +1 -0
  24. django_nepkit-0.1.0/django_nepkit.egg-info/requires.txt +5 -0
  25. django_nepkit-0.1.0/django_nepkit.egg-info/top_level.txt +2 -0
  26. django_nepkit-0.1.0/example/demo/__init__.py +0 -0
  27. django_nepkit-0.1.0/example/demo/admin.py +42 -0
  28. django_nepkit-0.1.0/example/demo/apps.py +5 -0
  29. django_nepkit-0.1.0/example/demo/migrations/0001_initial.py +2113 -0
  30. django_nepkit-0.1.0/example/demo/migrations/0002_alter_person_phone_number.py +18 -0
  31. django_nepkit-0.1.0/example/demo/migrations/0003_person_created_at_person_updated_at.py +27 -0
  32. django_nepkit-0.1.0/example/demo/migrations/0004_alter_person_created_at_alter_person_updated_at.py +23 -0
  33. django_nepkit-0.1.0/example/demo/migrations/0005_alter_person_created_at_alter_person_updated_at.py +27 -0
  34. django_nepkit-0.1.0/example/demo/migrations/__init__.py +0 -0
  35. django_nepkit-0.1.0/example/demo/models.py +27 -0
  36. django_nepkit-0.1.0/example/demo/tests.py +1 -0
  37. django_nepkit-0.1.0/example/demo/urls.py +9 -0
  38. django_nepkit-0.1.0/example/demo/views.py +32 -0
  39. django_nepkit-0.1.0/example/example_project/__init__.py +0 -0
  40. django_nepkit-0.1.0/example/example_project/settings.py +76 -0
  41. django_nepkit-0.1.0/example/example_project/urls.py +8 -0
  42. django_nepkit-0.1.0/example/example_project/wsgi.py +7 -0
  43. django_nepkit-0.1.0/example/manage.py +24 -0
  44. django_nepkit-0.1.0/pyproject.toml +72 -0
  45. django_nepkit-0.1.0/setup.cfg +4 -0
  46. django_nepkit-0.1.0/setup.py +39 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sankalp Tharu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,3 @@
1
+ include LICENSE
2
+ include README.md
3
+ recursive-include django_nepkit/static *
@@ -0,0 +1,377 @@
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).