Create repeating datetimes in django using dateutil rrulesets
Project description
Create repeating datetimes in Django using dateutil rrulesets with timezone awareness.
Free software: MIT license
Documentation: https://django-recurring.readthedocs.io
Features
Create complex recurring date patterns using dateutil rrulesets
Automatically calculate previous and next occurrences for efficient date range queries
Timezone-aware datetime handling
Export recurrence sets to iCal format
Admin interface with custom widget for creating and editing recurrence patterns
Limitations
This library currently has the following limitations.
- All date ranges require an end date.
The count param isn’t supported.
PRs welcome.
Quick Start
Install django-recurring:
pip install django-recurringAdd ‘recurring’ to your INSTALLED_APPS:
INSTALLED_APPS = [ ... 'recurring', ]Run migrations:
python manage.py migrate recurringAdd a RecurrenceSet to your model:
from django.db import models from recurring.models import RecurrenceSet class Event(models.Model): name = models.CharField(max_length=200) recurrence = models.ForeignKey(RecurrenceSet, on_delete=models.CASCADE)Use the RecurrenceSet in your code:
from django.utils import timezone from recurring.models import RecurrenceSet, RecurrenceRule, RecurrenceSetRule # Create a RecurrenceSet recurrence_set = RecurrenceSet.objects.create(name="Weekly Meeting") # Create a RecurrenceRule rule = RecurrenceRule.objects.create( frequency=RecurrenceRule.Frequency.WEEKLY, interval=1, byweekday=[0] # Monday ) # Add a date range to the rule rule.date_ranges.create( start_date=timezone.now(), end_date=timezone.now() + timezone.timedelta(days=365) ) # Link the rule to the RecurrenceSet RecurrenceSetRule.objects.create( recurrence_set=recurrence_set, recurrence_rule=rule ) # Recalculate occurrences recurrence_set.recalculate_occurrences() # Query events within a date range events = Event.objects.filter( recurrence__next_occurrence__gte=timezone.now(), recurrence__previous_occurrence__lte=timezone.now() + timezone.timedelta(days=30) )Export to iCal format:
ical_string = recurrence_set.to_ical() with open('weekly_meeting.ics', 'w') as f: f.write(ical_string)
For more detailed usage and examples, see the documentation.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_recurring-0.1.0.tar.gz.
File metadata
- Download URL: django_recurring-0.1.0.tar.gz
- Upload date:
- Size: 304.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d9b1be5089d053397f9c67312418762241cdfe4dc1463234a72d81338ef410e
|
|
| MD5 |
2928628bba9d21de85f76d8152d847f6
|
|
| BLAKE2b-256 |
813ddcf2aeac8902a3047cfb38cbe8619d784997ee668834ad2b8616d740ba08
|
File details
Details for the file django_recurring-0.1.0-py3-none-any.whl.
File metadata
- Download URL: django_recurring-0.1.0-py3-none-any.whl
- Upload date:
- Size: 34.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
18a2b1d1e98a3ab9e9581393c59f75e613f8415e1fa8ee916d0a75ae72c856f0
|
|
| MD5 |
abb8b424b74518e4dbe47edfd1b8adf9
|
|
| BLAKE2b-256 |
2b9804579e04f1106649539761b7f0edffa2c2ebde56607b7eab4be614a25dcd
|