Django_weekend is a Django library that offers a straightforward and adaptable solution for keeping track of weekends and working days. It provides functionality to determine if a particular date falls on a weekend or a working day, making it easy to manage and manipulate dates in Django projects.
# Table of contents
- [Installation](#installation)
- [Setup](#setup)
- [Usage](#usage)
# Installation
[(Back to top)](#table-of-contents)
- Download and install latest version of django_weekend:
```python
pip install django_weekend
```
- Add 'django_weekend' application to the INSTALLED_APPS setting of your Django project settings.py file:
```python
INSTALLED_APPS = (
...
'django_weekend',
)
```
- Create database tables:
```python
python manage.py migrate django_weekend
```
**⚠ Attension: By default django_weekend makes all days is working days. You can change this here `admin/django_weekend/commonworkingweeksettings/`**
# Setup
[(Back to top)](#table-of-contents)
There are three tables for tracking weekends:
- `CommonWorkingWeekSettings` is used to store working days
- `ExcludedWeekends` is used to store dates of days that are usually weekends but not on the saved date
- `Holidays` is used to store holidays dates
First of all, you need to set up you common schedule in `CommonWorkingWeekSettings`. By default, django_weekend sets up all 7 days as working days. However, you can change it as you want.
*NOTE!* django_weekend uses the following available days: `AVAILABLE_DAYS = ('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday')`. Other day names are not available to save.
To add excluded weekends, you can create a new entry in the ExcludedWeekends table. This will allow you to specify dates that are usually weekends but should be treated as working days.
When calculating working days, `CommonWorkingWeekSettings` will be used as the default schedule. However, if a date is listed in the `ExcludedWeekends` table, it will be considered a working day regardless of the settings in `CommonWorkingWeekSettings`.
For adding holidays, you can use the `Holidays` table. This table will override all other settings and mark the specified dates as holidays.
# Usage
[(Back to top)](#table-of-contents)
To determine whether a specific date is a weekend or not, you can use the is_weekend_by_date() method provided by the HolidaysWeekendsService class. This method returns a boolean value indicating whether the given date is a weekend or not. Here's an example of how to use it:
After set up all settings you can use this:
```python
from django_weekend.services import HolidaysWeekendsService
result = HolidaysWeekendsService().is_weekend_by_date(date='2023-11-11')
```
In the above code, date='2023-11-11' is the date for which you want to check if it's a weekend or not. The result variable will contain a boolean value indicating whether the date is a weekend (True) or not (False).
```python
>>result=True
```
----
You can also retrieve a list of weekend dates within a specified date range using the get_weekends_by_range() method. To do this, you'll need to import the HolidaysWeekendsService class from the django_weekend.services module.
Here's an example of how to use the get_weekends_by_range() method:
```python
from django_weekend.services import HolidaysWeekendsService
result = HolidaysWeekendsService().get_weekends_by_range(start_date='2023-11-11', end_date='2023-11-15')
```
In the code above, the start_date parameter is set to '2023-11-11' and the end_date parameter is set to '2023-11-15'. Calling the get_weekends_by_range() method will return a list of weekend dates within that date range.
For example, the result might be:
```python
>>result=['2023-11-11', '2023-11-12']
```
This means that '2023-11-11' and '2023-11-12' are the weekends within the specified date range.
By utilizing the get_weekends_by_range() method, you can easily obtain a list of weekend dates for a given range in your Django project using the django_weekend library.
Raw data
{
"_id": null,
"home_page": "https://github.com/MaksimJames/django_weekend",
"name": "django-weekend",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "django calendar settings weekend",
"author": "Maksim Prilepsky",
"author_email": "maksimprilepsky@yandex.ru",
"download_url": "https://files.pythonhosted.org/packages/29/6f/6a8d1ff49c247f35dbf04315dc8f75ad941598a60ab2ac362e1dc2cd6644/django_weekend-0.0.6.3.tar.gz",
"platform": null,
"description": "Django_weekend is a Django library that offers a straightforward and adaptable solution for keeping track of weekends and working days. It provides functionality to determine if a particular date falls on a weekend or a working day, making it easy to manage and manipulate dates in Django projects.\n\n\n# Table of contents\n\n- [Installation](#installation)\n- [Setup](#setup)\n- [Usage](#usage)\n\n# Installation\n\n[(Back to top)](#table-of-contents)\n\n- Download and install latest version of django_weekend:\n\n```python\npip install django_weekend\n```\n\n\n- Add 'django_weekend' application to the INSTALLED_APPS setting of your Django project settings.py file:\n\n```python\nINSTALLED_APPS = (\n ...\n 'django_weekend',\n)\n```\n\n\n- Create database tables:\n\n```python\npython manage.py migrate django_weekend\n```\n\n\n**\u26a0 Attension: By default django_weekend makes all days is working days. You can change this here `admin/django_weekend/commonworkingweeksettings/`**\n\n\n# Setup\n\n[(Back to top)](#table-of-contents)\n\nThere are three tables for tracking weekends:\n- `CommonWorkingWeekSettings` is used to store working days\n- `ExcludedWeekends` is used to store dates of days that are usually weekends but not on the saved date\n- `Holidays` is used to store holidays dates\n\nFirst of all, you need to set up you common schedule in `CommonWorkingWeekSettings`. By default, django_weekend sets up all 7 days as working days. However, you can change it as you want.\n\n*NOTE!* django_weekend uses the following available days: `AVAILABLE_DAYS = ('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday')`. Other day names are not available to save.\n\nTo add excluded weekends, you can create a new entry in the ExcludedWeekends table. This will allow you to specify dates that are usually weekends but should be treated as working days.\n\nWhen calculating working days, `CommonWorkingWeekSettings` will be used as the default schedule. However, if a date is listed in the `ExcludedWeekends` table, it will be considered a working day regardless of the settings in `CommonWorkingWeekSettings`.\n\nFor adding holidays, you can use the `Holidays` table. This table will override all other settings and mark the specified dates as holidays.\n\n\n# Usage\n\n[(Back to top)](#table-of-contents)\n\nTo determine whether a specific date is a weekend or not, you can use the is_weekend_by_date() method provided by the HolidaysWeekendsService class. This method returns a boolean value indicating whether the given date is a weekend or not. Here's an example of how to use it:\n\nAfter set up all settings you can use this:\n```python\nfrom django_weekend.services import HolidaysWeekendsService\n\n\nresult = HolidaysWeekendsService().is_weekend_by_date(date='2023-11-11')\n```\nIn the above code, date='2023-11-11' is the date for which you want to check if it's a weekend or not. The result variable will contain a boolean value indicating whether the date is a weekend (True) or not (False).\n```python\n>>result=True\n```\n\n\n----\nYou can also retrieve a list of weekend dates within a specified date range using the get_weekends_by_range() method. To do this, you'll need to import the HolidaysWeekendsService class from the django_weekend.services module.\n\nHere's an example of how to use the get_weekends_by_range() method:\n\n```python\nfrom django_weekend.services import HolidaysWeekendsService\n\nresult = HolidaysWeekendsService().get_weekends_by_range(start_date='2023-11-11', end_date='2023-11-15')\n```\n\nIn the code above, the start_date parameter is set to '2023-11-11' and the end_date parameter is set to '2023-11-15'. Calling the get_weekends_by_range() method will return a list of weekend dates within that date range.\n\nFor example, the result might be:\n\n```python\n>>result=['2023-11-11', '2023-11-12']\n```\nThis means that '2023-11-11' and '2023-11-12' are the weekends within the specified date range.\n\nBy utilizing the get_weekends_by_range() method, you can easily obtain a list of weekend dates for a given range in your Django project using the django_weekend library.\n\n",
"bugtrack_url": null,
"license": "",
"summary": "A simple library for tracking weekends and working days",
"version": "0.0.6.3",
"project_urls": {
"GitHub": "https://github.com/MaksimJames/django_weekend",
"Homepage": "https://github.com/MaksimJames/django_weekend"
},
"split_keywords": [
"django",
"calendar",
"settings",
"weekend"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "09d4fe0f2499b67792b50ea9cc631e8a9ad6b15afd588d04da42245fe1a8b59a",
"md5": "3bc9ad93c60927fa4d854c84db007e91",
"sha256": "c6c21dee5a21c82acc4c624176cb8cb9010f71da47c6b91fd9246b7f566b61dd"
},
"downloads": -1,
"filename": "django_weekend-0.0.6.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3bc9ad93c60927fa4d854c84db007e91",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 6537,
"upload_time": "2023-11-10T16:36:48",
"upload_time_iso_8601": "2023-11-10T16:36:48.098083Z",
"url": "https://files.pythonhosted.org/packages/09/d4/fe0f2499b67792b50ea9cc631e8a9ad6b15afd588d04da42245fe1a8b59a/django_weekend-0.0.6.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "296f6a8d1ff49c247f35dbf04315dc8f75ad941598a60ab2ac362e1dc2cd6644",
"md5": "02ba1d494b8986973ad31085ed15d004",
"sha256": "6779ab538c0a22ff3ff906bb4ffed1ce48710614f46565f25914b27042304b6e"
},
"downloads": -1,
"filename": "django_weekend-0.0.6.3.tar.gz",
"has_sig": false,
"md5_digest": "02ba1d494b8986973ad31085ed15d004",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 5207,
"upload_time": "2023-11-10T16:36:50",
"upload_time_iso_8601": "2023-11-10T16:36:50.225828Z",
"url": "https://files.pythonhosted.org/packages/29/6f/6a8d1ff49c247f35dbf04315dc8f75ad941598a60ab2ac362e1dc2cd6644/django_weekend-0.0.6.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-11-10 16:36:50",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "MaksimJames",
"github_project": "django_weekend",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "django-weekend"
}