Django nepali datetime 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
Hashes for django-nepali-datetime-field-0.6.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb92a6bd48a570580bd2dcdba9e2741694c5d3f116ef3864147007f699ab8f44 |
|
MD5 | 6db5f3a8364d694ff86dd683e5c08617 |
|
BLAKE2b-256 | c587838aecd772acb527c05d7b9f4d351be7ddb3bacf3849e707aca56cdd0346 |
Hashes for django_nepali_datetime_field-0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | de4a7d0c20d0d4ea38973b4f3f2c092130ffcfe65524992c5b96f5d60f5e3e50 |
|
MD5 | 882f999ce38df58aa43c1619d9f23e83 |
|
BLAKE2b-256 | bdc1fc483c608ab2b952124b00d126b19be94f1b1cff9498c10b9b0141da90dd |