Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement NepaliDateField for Django Models and Forms #5

Open
aj3sh opened this issue May 24, 2023 · 1 comment
Open

Implement NepaliDateField for Django Models and Forms #5

aj3sh opened this issue May 24, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@aj3sh
Copy link
Member

aj3sh commented May 24, 2023

As an extended package of 'nepali', we need to create a new field called NepaliDateField in Django that supports Nepali dates. This field will be used in both Django models and forms.

Model Usage

Initialization

class MyNepaliInfo(models.Model):
    ...
    birthday = NepaliDateField(...)
    ...

Saving data

This field will support both Python's date and nepalidate.

info = MyNepaliInfo()
info.birthday = nepalidate(2051, 4, 29)  # nepali date
...
info.save()

# OR
info.birthday = datetime.date(1994, 8, 13)  # Python's date

# OR

MyNepaliInfo.objects.create(
    ...
    birthday = nepalidate(2051, 4, 29),
    ...
)

Filtering

Filtering should be done by both Python's date and nepalidate. Also, user should be able to filter with nepali date's year, month, or day.

# filtering with nepalidate
MyNepaliInfo.objects.filter(birthday=nepalidate(2051, 2, 29))

# filtering with Python's date
MyNepaliInfo.objects.filter(birthday=date(1994, 8, 13)

# date range filtering
MyNepaliInfo.objects.filter(birthday__range=(nepalidate1, nepalidate2))
MyNepaliInfo.objects.filter(birthday__gt=nepalidate1)

# Filtering with Nepali year, same goes for the month and day
MyNepaliInfo.objects.filter(birthday__year=2051)

# Filtering with English year
MyNepaliInfo.objects.filter(birthday__year_en=1994)

Form Usage

Initialization

class MyNepaliInfoForm(forms.Form):
    ...
    birthday = NepaliDateFormField(...)
    ...

...

@aj3sh aj3sh changed the title NepaliDateTime model/form field Add support for NepaliDateTime model/form field Jun 2, 2023
@aj3sh aj3sh changed the title Add support for NepaliDateTime model/form field Implement NepaliDateField for Django Models and Forms Jun 3, 2023
@aj3sh
Copy link
Member Author

aj3sh commented Jun 3, 2023

Let's start with a POC. cc: @sugat009

@aj3sh aj3sh added the enhancement New feature or request label Jul 16, 2023
@aj3sh aj3sh self-assigned this Jul 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: In Progress
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant