Skip to main content

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

  1. Add nepali_datetime_field to your INSTALLED_APPS list:

    INSTALLED_APPS = [
        ...
        'nepali_datetime_field',
    ]
  2. Importing NepaliDateField model field to models.py file:

    from nepali_datetime_field.models import NepaliDateField
    
    class YourModel(models.Model):
        ...
        nepali_date = NepaliDateField()
  3. Importing NepaliDateField form field to forms.py file:

    from nepali_datetime_field.forms import NepaliDateField
    
    class YourForm(forms.Form):
        ...
        nepali_date = NepaliDateField()
  4. 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>
  5. 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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_nepali_datetime_field-0.7.1.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file django_nepali_datetime_field-0.7.1.tar.gz.

File metadata

File hashes

Hashes for django_nepali_datetime_field-0.7.1.tar.gz
Algorithm Hash digest
SHA256 e9790bae8c0d183612379bc8d572c5ced069926ab7b99ee51a788540f3deb216
MD5 517b441e71a180693447bc2cdc2060a4
BLAKE2b-256 5fd1775dcb09c358f1238196876771696be40222dd9b7cce111fbc7d74ce21a3

See more details on using hashes here.

File details

Details for the file django_nepali_datetime_field-0.7.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_nepali_datetime_field-0.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9ee7706d9de186cbcc6d8ff69733c35b8c4439d5d1bab99d09dc0bf886249caf
MD5 8633a640f48ae582de93d311718c7903
BLAKE2b-256 c03ac26156b7999dff8466d27d927c981941c5258acbfd52d7b5807a9de12818

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page