Django nepali datetime fields and helpers.
Project description
Highly motivated package from Django’s DateField & DateTimeField. The library is intended to provide Bikram Sambat Date Time fields for Django’s Model and Form.
Note: Currently only supports DateField. DateTimeField will be supported soon in future releases.
The package is dependent on nepali-datetime package and the UI for the date picker is implemented from https://github.com/leapfrogtechnology/nepali-date-picker.
Supports: Django 2.0+
Installation
$ pip install django-nepali-datetime-field
Quick start
Add nepali_datetime_field to your INSTALLED_APPS list:
INSTALLED_APPS = [ ... 'nepali_datetime_field', ]
Importing NepaliDateField model field to models.py file:
from nepali_datetime_field.models import NepaliDateField class YourModel(models.Model): ... nepali_date = NepaliDateField()
Importing NepaliDateField form field to forms.py file:
from nepali_datetime_field.forms import NepaliDateField class YourForm(forms.Form): ... nepali_date = NepaliDateField()
Whenever using NepaliDateField form field, don’t forget to add Widget’s media on the <head> section of the html as below:
<html> <head> ... {{ form.media }} ... </head> <body> ... {{ form }} ... </body> </html>
Querying the model field:
import nepali_datetime nepali_date = nepali_datetime.date(1995,10,1) # get query YourModel.objects.get(nepali_date=nepali_date) # filter query YourModel.objects.filter(nepali_date=nepali_date) # date range query from_date = nepali_datetime.date(1990,1,1) to_date = nepali_datetime.date(1999,12,30) YourModel.objects.filter(nepali_date__range=(from_date, to_date))
More Usage
Check some of the usage details in example_app/tests.py.
Demo
Play around with the live demo here.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django_nepali_datetime_field-0.7.tar.gz
.
File metadata
- Download URL: django_nepali_datetime_field-0.7.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.8.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e0e6e87c14670e05bd921696fe5ab37f6588f4be0d8e1fb60078aabb3d34b3c |
|
MD5 | cbb7c3e1967ce01bcb39c72f40eacee4 |
|
BLAKE2b-256 | 43e372fec6bf166598749b1169b370d2247f7814e1f322e134fd15fe4e823f2c |
File details
Details for the file django_nepali_datetime_field-0.7-py3-none-any.whl
.
File metadata
- Download URL: django_nepali_datetime_field-0.7-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.8.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd4dafbcab010c6c1007559ac705ade9f47ef46a50575ef850749d5375c92e3d |
|
MD5 | 281a2824a8a56b4d603241f8cb74b5a1 |
|
BLAKE2b-256 | 8c5419b95caf028aada53f161cb922ce378d48a19c93d29253b74ed260b595fa |