django-recurrence is a utility for working with recurring dates in Django. It provides `Recurrence/Rule` objects based on a subset of rfc2445 (wrapping `dateutil.rrule`), a `RecurrenceField` for database storage, and a JavaScript widget for user input. The library is currently at version 1.14 and is actively maintained by the Jazzband community, with regular releases to support new Django and Python versions.
pip install django-recurrenceVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to define a model with `RecurrenceField`, populate it with a basic weekly recurrence rule, and then retrieve occurrences within a date range. It also highlights the importance of setting `dtstart` when querying for occurrences across a range, especially for past events.
Ensure your project uses Python 3.9+ and Django 4.2+ (preferably 5.2+ for the latest support) before upgrading to django-recurrence 1.13 or newer.
Upgrade your Django project to version 4.0 or newer and Python to 3.9 or newer before installing or upgrading to django-recurrence 1.12 or newer.
Always explicitly provide the `dtstart` parameter (e.g., `dtstart=datetime(year, month, day)`) to specify the desired start of the recurrence pattern for accurate results across the full range you intend to query. Set `inc=True` if you want to include the `dtstart` or `dtend` date in the results if it's an occurrence.
If your application requires precise time and timezone handling for recurring events, ensure your Django project is configured for timezone support (`USE_TZ = True`), and consider storing event start/end times in a `DateTimeField` rather than a `TimeField` for better integration and timezone awareness, managing the `datetime` objects returned by recurrence. Explicitly set `tzinfo` when creating `datetime` objects for recurrence calculations.
1. Add `'recurrence'` to your `INSTALLED_APPS`. 2. Ensure `django.contrib.staticfiles` is also in `INSTALLED_APPS` and run `python manage.py collectstatic`. 3. In your `urls.py`, include the `javascript_catalog` view: `from django.urls import re_path as url; from django.views.i18n import JavaScriptCatalog; js_info_dict = {'packages': ('recurrence', )}; urlpatterns += [url(r'^jsi18n/$', JavaScriptCatalog.as_view(), js_info_dict), ]`. 4. In your template, include `{{ form.media }}` within the `<head>` section.First, install the package: `pip install django-recurrence`. Then, ensure `'recurrence'` is included in your `INSTALLED_APPS` tuple in your Django project's `settings.py` file.
To delete a single occurrence, you must add an `EXDATE` (Exclusion Date) property to the recurrence rule for that specific date. To edit a single occurrence (e.g., change its time or title), you typically treat it as an `EXDATE` and create a new, separate single-day event (or `RDATE`) for the modified occurrence, while leaving the main recurrence rule untouched.