jazzband / django-recurrence Goto Github PK
View Code? Open in Web Editor NEWUtility for working with recurring dates in Django.
Home Page: https://django-recurrence.readthedocs.org/
License: BSD 3-Clause "New" or "Revised" License
Utility for working with recurring dates in Django.
Home Page: https://django-recurrence.readthedocs.org/
License: BSD 3-Clause "New" or "Revised" License
I am using this to generate a range of instances of a model (Event) based on the rules set at creation time but I want the form that produces them to redirect to a page which lists all the generated occurrences, once they've been created.
Is there an easy way to do this or do I have to manage it myself using a new model to connect them all or something maybe?
I was kind of hoping I could do something like
event.recurrences.instances()
to get hold of them.
Or is this something I would have to manage myself?
First, I was really pleased to find this app. It is going to be a huge help for me. Thanks.
I was a little surprised, for the monthly repeating, to see First, Second, Third and Last. But no Fourth. Is there a reason not to have a Fourth. Is there a reason? I must be missing something.
Release notes for all the changes since 1.0.3 are at https://django-recurrence.readthedocs.org/en/latest/changelog.html.
Could you cut a release, @emperorcezar?
I recently moved over to django 1.8 and Python3. I completely understand that this is experimental for Python 3 and is valid for up to Django 1.7 but I am having an issue.
I continue to get Uncaught ReferenceError: pgettext is not defined. I tried following the instructions:
js_info_dict = {
'packages': ('recurrence', ),
}
# jsi18n can be anything you like here
urlpatterns += patterns(
(r'^jsi18n/$', 'django.views.i18n.javascript_catalog', js_info_dict),
)
but I am still getting errors. I am not sure if the errors are "expected" with Django 1.8 or if I might be just doing something wrong.
The error is at:
recurrence.display.weekdays_oneletter = [
pgettext('Monday first letter', 'M'), <-- Here
pgettext('Tuesday first letter', 'T'),
pgettext('Wednesday first letter', 'W'),
though is probably not too surprising. :-)
Any ideas would be appreciated.
I'm trying to schedule a biweekly recurrence (every other Friday), but it seems to set the starting Friday automatically? Is it possible to specify the Friday it starts on and I'm just missing it?
When runing this package with Django 1.9.1 I'm getting the warning:
RemovedInDjango110Warning: SubfieldBase has been deprecated.
Use Field.from_db_value instead.
Because the field:
class RecurrenceField(with_metaclass(SubfieldBase, fields.Field)):
"""
Field that stores a `recurrence.base.Recurrence` object to the
database.
"""
Extends the SubfieldBase
.
I'm seeing incorrect occurrences when defining a recurrence in the following way:
(new rule) Daily, until some date, or occurs N times
(new date) Excluding some date
My Django model my_object
has a RecurrenceField
named recurrences
. Today is March 24th, I define a daily rule on every day until March 29th and I exclude Friday March 28th.
list(my_object.recurrences.occurrences())
produces:
[datetime.datetime(2014, 3, 25, 0, 42, 44), datetime.datetime(2014, 3, 26, 0, 42, 44), datetime.datetime(2014, 3, 27, 0, 42, 44), datetime.datetime(2014, 3, 28, 0, 42, 44), datetime.datetime(2014, 3, 29, 0, 42, 44)]
which seems incorrect, as it includes datetime.datetime(2014, 3, 28, 0, 42, 44)
.
Digging in, it seems that the exdates
are matched "exactly" and that any difference in the hour values will produce seemingly incorrect occurrences, as seen above.
Fetching my_object.recurrences.exdates[0]
returns datetime.datetime(2014, 3, 28, 4, 0)
.
If I then fetch my_object.recurrences.occurrences(dtstart=datetime(2014, 3, 24, 4)))
I do see that March 28th is excluded:
[datetime.datetime(2014, 3, 24, 4, 0), datetime.datetime(2014, 3, 25, 4, 0), datetime.datetime(2014, 3, 26, 4, 0), datetime.datetime(2014, 3, 27, 4, 0), datetime.datetime(2014, 3, 29, 4, 0)]
Any ideas how to fix this? :-) Cheers!
Thank you for so much for this great project!
I'm working on Django 1.8 project with Russian language and i want use your application. But i can't deal with languages in it. I found different locales in recurrence/locale
and i know how gettext is working but when i change my default Django language to some locale that are already presented in locale
e.g. i set
LANGUAGE_CODE = 'fr'
admin language are changing to French language, but recurrence widget is still in English. Also i add js i18n url:
js_info_dict = {
'packages': ('recurrence', ),
}
# jsi18n can be anything you like here
urlpatterns += (
url(r'^jsi18n/$', 'django.views.i18n.javascript_catalog', js_info_dict),
)
But JS widget is still use English. What am i doing wrong?
ps. I want to add Russian localization on reccurence project but at this point i can't uderstand why i18n doesn't work for me.
Using the minimal Course
model from the docs, I've created the following template, and a suitable create view and model form to match:
<!DOCTYPE html>
<html lang="en_US">
<head>
{{ form.media }}
</head>
<body>
<h1>Create Course</h1>
<form action="" method="post">{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Submit" />
</form>
</body>
</html>
However, when actually accessing this view, I see these three errors show up in Firebug, and the recurrence field is rendered as just a plain text input.
ReferenceError: django is not defined
if (!django.catalog) {
ReferenceError: gettext is not defined
'inclusion': gettext('including'), 'exclusion': gettext('excluding')
TypeError: recurrence.display.labels is undefined
recurrence.display.labels.add_rule, {
This is using django-recurrence==1.0.3, pip installed from PyPI.
It isn't stated clearly in the docs anywhere, and it seems like there are conflicting opinions in both how this library handles dtstart. In the docstrings for base.py
and Recurrence
it does seem to indicate that dtstart
is handled the according the RFC 2445, which uses it as both the starting point for recurrences and as the first recurrence returned.
This is in contrast to how dateutil.rrule
handles it, which just uses dtstart
as the starting point for recurrences and does not automatically add it as the first occurrence.
It looks like this can be a bit of a pain point for users. #50 #36
Should this be better documented somewhere, to explicitly state that it doesn't follow the way dateutil.rrule
handles dtstart
and follows more closely to the spec. Or should changing the behavior be considered since it appears to cause issues? I recognize that this would be a big change.
The javascript part of RecurrenceWidget should include a way to add a start date to a rule. Right now none is saved. This leads to a dtstart of datetime.now() when the occurrences are generated.
For most users this is probably not a desired behavior.
When I set an rdate or exdate through the widget it makes a new date using my browser's timezone, if the date is in a daylight savings time period it includes that info:
2017-01-20 -> 2017-01-20 T050000 (EST)
2017-04-21 -> 2017-04-21 T040000 (EDT)
What happens is that gets passed to the recurrence field as:
EXDATE:20170120T050000Z
EXDATE:20170421T040000Z
The deserialize function puts that into UTC time and stores them as:
2017-01-20 00:00:00
2017-04-20 23:00:00
The deserialize function doesn't take into account the daylight savings time on the 04-21 date and subtracts 5 hours instead of 4 and when displayed the date is then off (excludes April 20th instead of April 21st)
I am not sure exactly where this is happening, somewhere its getting the EXDATE:20170421T040000Z and adding the localtz as EST not EDT and takes 5 hours off not 4 hours resulting in the error.
edit
Figured it out - settings.TIME_ZONE
was set to EST
and it needed to be US/Eastern
We appear to not be alone here - e.g. https://github.com/bread-and-pepper/django-userena/issues/480. We've not changed anything that could break this - tests that used to pass on Travis are now failing.
Filing to track progress on getting this fixed.
The following failing test describes the issue:
It's an edge-case that only occurs with between() when the Recurrence is daily and the exclusion is Feb 29th and dtstart isn't filled in.
I've been able to easily work around it by either setting dtstart or providing an alternative exclusion rule, but I'm noting this issue in case anyone else stumbles upon it (today or over 4 years).
When generating weekly occurrences that cross a dst change boundary for an aware base datetime, the time in the normalized datetimes doesn't stay the same.
For example, for
2014-10-22 10:30 CEST
with a weekly recurrence, the next generated datetime is
2014-10-29 10:30 CEST
, which normalizes to
2014-10-29 9:30 CET
. What I want though is
2014-10-29 10:30 CET
.
We work around that by passing only naive datetimes as dtstart to recurrences:
tz = timezone.get_default_timezone()
dtstart = timezone.make_naive(self.start_datetime, tz)
return map(lambda o: timezone.make_aware(o, tz),
self.recurrence.occurrences(dtstart=dtstart, dtend=dtend))
I wouldn't say the current implementation is necessarily wrong - it's just a different use case, where each occurrence is exactly 7*24 hours apart. I'd argue though that the other use case is more common.
I don't have time right now to tackle this myself. However, in the long run I'd like to get the workaround out of our code.
Hi,
i want to set event recurrences in the admin widget with a start date but i dont find how to do this, start date of my rules automatically take a datetime.now()
from datetime import datetime
import recurrence
myrule = recurrence.Rule(
recurrence.DAILY
)
pattern = recurrence.Recurrence(
dtstart=datetime(2015, 10, 2, 0, 0, 0),
dtend=datetime(2015, 10, 9, 0, 0, 0),
rrules=[myrule, ]
)
It thats i want, i got an event started a 2october with daily recurences to 9 october, i check to python dateutil and its easy to do this directly with it too. In your app i really enjoy the admin widget, my users can easy enter complex recursive events with it, but if they can't set a start date will difficult.
in recurrence.fields we can see this : " Field that stores a recurrence.base.Recurrence
object to the
database."
Ok i go in base.Recurrence i see this :
`dtstart` : datetime.datetime
Optionally specify the first occurrence. This defaults to
`datetime.datetime.now()` when the occurrence set is
generated.
Im in this case, it generate me an automatic start date.
In recurrences.forms.RecurrenceField :
`accept_dtstart` : bool
Whether to accept a dtstart value passed in the input.
Im really confuse, how to set a dtstart in the input?
Thanks for your help
The code comments state that by default all frequencies are enabled. However in reality in django admin only the first 4 are enabled.
How can I enable all recurrence frequencies? ie Hourly, Minutely.
(Could be solved by better documentation #23)
The line: recurrences = recurrence.fields.RecurrenceField() requires an import statement for recurrence.
Something like: import recurrence
In the documentation I clearly see that there are only options for getting the occurrences for every single model object. Is there any way to filter the queryset using the recurrence field ?
For example, Can I filter the queryset by finding which all events that has recurrences for today ? (similar to http://swingtime.nerdfog.com/docs/models.html#occurrencemanager). It is fine if I take all the rows from the db and query in the python code since I am going to have 10 rows at the most.
I have been looking at django-eventtools. eventtools seems not having the form widget as recurrence field. Just curious to know if there are any possiblilities in django-recurrence.
# recurrence/base.py
class Recurrence(object):
def __nonzero__(self):
if (self.dtstart or self.dtend or
tuple(self.rrules) or tuple(self.exrules),
tuple(self.rdates) or tuple(self.exdates)):
return True
else:
return False
It seems like this function always returns True since the comma here makes the tested expression a two-tuple which is True in boolean context.
See also 0fdde40#commitcomment-7619127
This project looks like may be quite useful, but it could really use some documentation.
fields.py
still uses Creator
from django.db.models.fields.subclassing
which is removed in Django 1.10.
Is 1.4.0 planned to be released soon, Django 1.10 was released on August, 1st and the current version 1.3.0 is not compatible.
Currently, I'm finding it difficult to use this code because it requires that I look under the hood quite a bit. I am still unsure when/where to use the RecurrenceField as opposed to the RecurrenceModelField in the Event model that I've defined in my project.
Good example usage in the documentation at the models.py and views.py level will make this project more accessible to individuals that have time constraints.
As per title, when trying to use the two together, I obtain this:
Basically, the widget is rendered under the other parts of the form, and I'm unable to fix it without messing up with the css code... I don't know if I'd rather ask django-admin-bootstrap developers, but I hope you can point me somewhere with this. Thank you for your help!
On submitting the main form browser prompts unsaved changes warning when rule or date was added.
It's bad for user experience
It seems that in every single rule or date a form tag was used, I guess that what causes this bad experience or I made something wrong?
Currently, tox.ini has:
envlist = {py26}-{14,15,16},{py27}-{14,15,16,17},{py33,py34}-{15,16,17},docs,flake8
We should probably drop official support for Python 2.6 entirely, and start testing Django 1.8 and 1.9. We should also probably stop testing Django 1.4-1.7, since those are also EOL (see the docs). We should also start testing with Python 3.5.
This will help with work on #63.
Please consider adding an optional "time" parameter.
So when you try to run the installation and obtain the following:
Traceback (most recent call last):
File "manage.py", line 10, in
execute_from_command_line(sys.argv)
File "/home/envs/event_system/lib/python3.4/site-packages/django/core/management/init.py", line 385, in execute_from_command_line
utility.execute()
File "/home/envs/event_system/lib/python3.4/site-packages/django/core/management/init.py", line 354, in execute
django.setup()
File "/home/envs/event_system/lib/python3.4/site-packages/django/init.py", line 21, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/envs/event_system/lib/python3.4/site-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/home/envs/event_system/lib/python3.4/site-packages/django/apps/config.py", line 87, in create
module = import_module(entry)
File "/home/envs/event_system/lib/python3.4/importlib/init.py", line 104, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 2231, in _gcd_import
File "", line 2214, in _find_and_load
File "", line 2203, in _find_and_load_unlocked
File "", line 1200, in _load_unlocked
File "", line 1129, in _exec
File "", line 1448, in exec_module
File "", line 321, in _call_with_frames_removed
File "/home/envs/event_system/lib/python3.4/site-packages/recurrence/init.py", line 1, in
from recurrence.base import (
File "/home/envs/event_system/lib/python3.4/site-packages/recurrence/base.py", line 850
except exceptions.ValidationError, error:
^
SyntaxError: invalid syntax
Therefore, the code does not compatible with Python3?
Creating a weekly Monday recurrence. Then getting all the occurrences between 2015-08-02 (Sunday) and 2015-08-11 (Tuesday) should return 2015-08-03 (Monday) and 2015-08-10 (Monday).
However, if I use the inc=True option to make start/end times inclusive and also use the dtstart option to specify the start date (lets me find occurrences in the past), it always includes the dtstart value as one of the occurrences.
Here is the code (version 1.2.0) demonstrating the bug:
recurrence.Recurrence(rrules=[recurrence.Rule(recurrence.WEEKLY, byday=recurrence.MONDAY)]).between(datetime.datetime(2015, 8, 2), datetime.datetime(2015, 8, 11), inc=True, dtstart=datetime.datetime(2015, 8, 2))
This results in:
[datetime.datetime(2015, 8, 2, 0, 0), datetime.datetime(2015, 8, 3, 0, 0), datetime.datetime(2015, 8, 10, 0, 0)]
Expected:
[datetime.datetime(2015, 8, 3, 0, 0), datetime.datetime(2015, 8, 10, 0, 0)]
Can we update the version of setup.py which is tagged at 1.0 to have the version 1.0? The mismatch between the two values is a bit confusing. I'm not familiar enough with tags to do this myself - if neither @tamask or @emperorcezar are, I'll figure it out.
I'm not sure if we should then update the version number in setup.py, to distinguish it from the 1.0 release - perhaps we should make it 1.1-dev or something similar?
@emperorcezar - there are quite a few bits in 1.4.1, so now seems like a good time to get a release out. Would you mind doing the honours?
Hi, I have a recurring rule object with this rule:
RRULE:FREQ=YEARLY;BYMONTH=11
When I use its to_text() method, I get:
annually, each December
And actually it should be 'anually, each November'
Léon
I have an event model that has a start and end time as well as a RecurrenceField, which is not required (not all events have recurrences). I've looked at the documentation and the tests, but it's not clear how one would get all recurrences for all event models without checking every event object for its recurrences. Is it possible to do something like this:
for item in Event.objects.filter(start__range=(start, end), recurrences=recurrences.between(start, end, dtstart=start, inc=True)):
//do something with event
The dateutil docs give examples like:
list(rrule(YEARLY, interval=4, count=3, bymonth=11,
byweekday=TU, bymonthday=(2,3,4,5,6,7,8),
dtstart=parse("19961105T090000")))
[datetime.datetime(1996, 11, 5, 9, 0),
datetime.datetime(2000, 11, 7, 9, 0),
datetime.datetime(2004, 11, 2, 9, 0)]
but we can't specify months AND days of week in the same rule in the django-recurrence widget
I need to specify a range for certain days of the week, but only for particular months of the year (for seasonal activities). I can achieve an example of this in python with:
list(rrule(YEARLY, bymonth=(1,2,3,7,9), byweekday=(SA,SU), count=10))
(list and count included for readability of output)
As awesome as django-recurrence is, each frequency tab (eg Annually, Weekly) only supports options relative to that type, so Annually doesn't let me specify for which weekdays, for example. I can add another rule, but that is a logical OR which means that dates are included if they match the first rule or the second rule.
One way around this would be for me to use an Exclude, but this seems to only be a single day in the month (when I choose Annually and my months). Let me know if I'm missing something here.
Another way would be an enhancement to the widget. It seems from the dateutil docs that the Frequency selected is only relevant for interval and bysetpos. This means that any Frequency can have day of week, week of year, etc. So the widget would need reworking so that regardless of Annually / Monthly / Weekly / Daily selected, the month, day of month, and day of week selectors would always be visible.
Discussion welcome
With Django 1.10 I get:
...
File "/home/jmk/.virtualenvs/home-budgets/lib/python3.5/site-packages/recurrence/fields.py", line 3, in <module>
from django.db.models.fields.subclassing import Creator
ImportError: No module named 'django.db.models.fields.subclassing'
Seems like there is an s
too much there. Shouldn't it be django.db.models.field.subclassing
?
I guess it's a 1.10 refactor.
I really like this project, but for my requirement I would also need the possibility to create some recurrences programmatically. I cannot seem to figure out how to create the recurrences attribute of a Course instance (example from your docs) by code.
Could you make a short addition to the docs on how to do this? Thanks!
Update:
I figured it out by looking into your tests. I will just add the steps should anyone be interested:
I'm finishing the Italian translation for django-recurrence (which I will release here of course, if you want).
There is a problem with the fifth month though. Its translation within the months table and the calendar widget seems to be referring to the same line, which is causing troubles, in sense that it's either like this:
or this:
I've noticed that on djangojs.po:390, you're passing from Apr to June, and May is skipped.
I was born in May, so it's double trouble for me :)
Joking apart, can this be fixed somehow?
Thanks.
Steps to reproduce:
from django.db import models
from recurrence.fields import RecurrenceField
class Event(models.Model):
name = models.CharField(max_length=100)
recurs = RecurrenceField(blank=True, null=True)
Then try saving implicit None
:
>>> from test_recurs.models import Event
>>> event = Event(name="foobar")
>>> event.save()
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/home/dom/.virtualenvs/recurrence/local/lib/python2.7/site-packages/django/db/models/base.py", line 463, in save
self.save_base(using=using, force_insert=force_insert, force_update=force_update)
File "/home/dom/.virtualenvs/recurrence/local/lib/python2.7/site-packages/django/db/models/base.py", line 551, in save_base
result = manager._insert([self], fields=fields, return_id=update_pk, using=using, raw=raw)
File "/home/dom/.virtualenvs/recurrence/local/lib/python2.7/site-packages/django/db/models/manager.py", line 203, in _insert
return insert_query(self.model, objs, fields, **kwargs)
File "/home/dom/.virtualenvs/recurrence/local/lib/python2.7/site-packages/django/db/models/query.py", line 1593, in insert_query
return query.get_compiler(using=using).execute_sql(return_id)
File "/home/dom/.virtualenvs/recurrence/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 911, in execute_sql
for sql, params in self.as_sql():
File "/home/dom/.virtualenvs/recurrence/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 872, in as_sql
for obj in self.query.objs
File "/home/dom/.virtualenvs/recurrence/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 292, in get_db_prep_save
prepared=False)
File "/home/dom/.virtualenvs/recurrence/local/lib/python2.7/site-packages/recurrence/fields.py", line 38, in get_db_prep_value
return recurrence.serialize(value)
File "/home/dom/.virtualenvs/recurrence/local/lib/python2.7/site-packages/recurrence/base.py", line 851, in serialize
raise exceptions.SerializationError(error.args[0])
SerializationError: incompatible object
Save explicit None
:
>>> event = Event(name="foobar", recurs=None)
>>> event.save()
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/home/dom/.virtualenvs/recurrence/local/lib/python2.7/site-packages/django/db/models/base.py", line 463, in save
self.save_base(using=using, force_insert=force_insert, force_update=force_update)
File "/home/dom/.virtualenvs/recurrence/local/lib/python2.7/site-packages/django/db/models/base.py", line 551, in save_base
result = manager._insert([self], fields=fields, return_id=update_pk, using=using, raw=raw)
File "/home/dom/.virtualenvs/recurrence/local/lib/python2.7/site-packages/django/db/models/manager.py", line 203, in _insert
return insert_query(self.model, objs, fields, **kwargs)
File "/home/dom/.virtualenvs/recurrence/local/lib/python2.7/site-packages/django/db/models/query.py", line 1593, in insert_query
return query.get_compiler(using=using).execute_sql(return_id)
File "/home/dom/.virtualenvs/recurrence/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 911, in execute_sql
for sql, params in self.as_sql():
File "/home/dom/.virtualenvs/recurrence/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 872, in as_sql
for obj in self.query.objs
File "/home/dom/.virtualenvs/recurrence/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 292, in get_db_prep_save
prepared=False)
File "/home/dom/.virtualenvs/recurrence/local/lib/python2.7/site-packages/recurrence/fields.py", line 38, in get_db_prep_value
return recurrence.serialize(value)
File "/home/dom/.virtualenvs/recurrence/local/lib/python2.7/site-packages/recurrence/base.py", line 851, in serialize
raise exceptions.SerializationError(error.args[0])
SerializationError: incompatible object
I'm pretty sure this used to work with the version of django-recurrence I bundled into my app (I discovered this when removing my bundled version and switching to django-recurrence 1.0).
I'll take a look at this, unless anyone has immediate ideas of what's wrong.
At this point in the code https://github.com/django-recurrence/django-recurrence/blob/master/recurrence/forms.py#L147 if the value you passed is None it will throw a TypeError, saying it expected a string or a buffer. Maybe a check should be done, if value is None then value = '' the empty string
I am using django-recurrence for a project. When I try to use the javascript widget for the form, it does not render correctly in the browser (both safari and chrome). Here's the screen shot
And here's the snippet for the html:
I am pretty sure the the static assets are loading correctly cuz the terminal prints out the static assets requests and it is serving the assets correctly.
Hi,
Thanks for this app really usefull, i use it for an event app.
The problem is i dont need time with my date, that just contrain me to do more loop for find events, i have try to change DateTimeField to DateField in models.py at line 8,9,25 and 36. After that i delete and recreate reccurence field im my events models, but i always get a DateTimeField.
my views and templates for exemple, i have a list of category that event match the date :
views :
def get_date1(request,date):
categ_array = []
eventDate = datetime.strptime(date,'%Y-%m-%d').date()
date_categ = Category.objects.all()
for categ in date_categ:
try:
getEvent = categ.event_set.all(is_cancelled=False)
for event in getEvent:
for occ in event.recurrences.occurrences():
if occ.date() == eventDate:
if categ not in categ_array:
categ_array.append(categ)
except:
pass
return render(request, 'agenda/date1.html', locals())
templates :
{% for categ in categ_array %}
<h2>{{categ.name}}</h2>
{% for event in categ.getEvent %}
{%for i in event.recurrences.occurrences%}
{% if i.date = eventDate %}
<li> {{event.title}}</li>
{% endif %}
{% endfor %}
{% endfor %}
{% endif %}
{% endfor %}
As you see i have to test "for i in event.recurrences.occurrences, if i.date = eventDate", if havent this Time field i could just do "if eventDate in event.recurrences.occurrences" i think my app can be more fast like that.
Thanks for your help
I have notice that the widget send Rdates, Exdates and Until dates in UTC format to the server like '20160725T230000Z' but looks like the widget got the timezone info from the browser instead of from the timezone setting
Other issue is that when I access the field information the dates don't have a timezone and it looks like they were converted to the current one.
My browser timezone is UTC+1 and my django TIME_ZONE UTC+2
So in my case the widget send '20160725T230000Z' (datetime.datetime(2016, 7, 25, 23, 0, tzinfo=tzutc())) and when I access the field it contains datetime.datetime(2016, 7, 26, 1, 0).
Any ideas, can this be fixed somehow? Thanks
It would be awesome if you could select recurrence to be the last working day of a month or year. https://github.com/novafloss/workalendar may be useful for this.
I have created a rule that should occur every year from 1st to 10th of december.
Rule definition:
RRULE:FREQ=MONTHLY;BYMONTHDAY=1,2,3,4,5,6,7,8,9,10
EXRULE:FREQ=YEARLY;BYMONTH=1,2,3,4,5,6,7,8,9,10,11
In [100]: robj = recurrence.deserialize(rule)
In [102]: robj.occurrences().after(datetime.datetime.utcnow())
Out[102]: datetime.datetime(2015, 3, 5, 18, 8, 40)
any ideas?
django=1.9.12
django-recurrence=1.4.1
When using recurrence in django admin, if recurrence is a field on an inline model and an instance of the inline model is spawned using the "Add whatever" button then the "Add Rule" and "Add Date" buttons in recurrence do not function. The recurrence widget functions normally if the inline object is visible when loading the page.
When one sets an exclude date in the admin ui, the exdate gets ignored by the between function. It seems that the admin ui passes a date object into the model, that is then cast into a datetime object resulting in timings like 00:00. Since the between function only matches against exact datetime, the exdate does not match.
>>> s.recurrences.dtstart
datetime.datetime(2017, 5, 7, 1, 0)
>>> s.recurrences.exdates
[datetime.datetime(2017, 5, 10, 0, 0)]
>>> s.recurrences.between(datetime.datetime(2017,5,9), datetime.datetime(2017,5,12))
[datetime.datetime(2017, 5, 9, 1, 0), datetime.datetime(2017, 5, 10, 1, 0), datetime.datetime(2017, 5, 11, 1, 0)]
When setting the correct time programmatically everything works as expected:
>>> s.recurrences.exdates[0] = datetime.datetime(2017, 5, 10, 1, 0)
>>> s.recurrences.exdates
[datetime.datetime(2017, 5, 10, 1, 0)]
>>> s.recurrences.between(datetime.datetime(2017,5,9), datetime.datetime(2017,5,12))
[datetime.datetime(2017, 5, 9, 1, 0), datetime.datetime(2017, 5, 11, 1, 0)]
I assume the date passed from the admin ui widget needs some kind of normalization to set a correct time or the exdate should be implemented time agnostic at all.
Hi...
I definitely don't solve my timezones problems, maybe i can got here some advice about this, or soon ill have no hair in my head :p
Settings.py :
TIME_ZONE = 'UTC'
USE_TZ = True
This isnt my local timezone ("Europe, Paris") but i have read that is better to work with UTC and just convert the output datetime if needed.
Explications :
No problem with rules, they seems work correctly, i can get all of them with my event app.
But when i enter a random date (in the admin widget), for exemple i create an occurrences for "2015-10-06", this is save at "2015-10-05 22:00" or "2015-10-05 23:00" that's depend... i have try to debug it at some place :
Im in french timezone on my computer, the javascript take the client timezone, normal.
When i save my model i have set a clean method like this :
def clean(self):
arrayocc = []
for i in self.recurrences.occurrences():
arrayocc.append(i)
raise ValidationError(arrayocc)
At this step thats raise me this date : 2015-10-05 22:00:00
That's look like a javascript date problem,no?
I got no problem when i use basic django dateTimeField in my models
At changelog for 1.2.0 in the docs :
Added a French translation (#32) - this may be backwards incompatible if have overriden the widget JavaScript such that there is no language_code member of your recurrence object;
For the moment i don't use the translation but i don't really understand what are you tell us here^^
i can perform more test if you want.
Hope im clear.
Thanks
Currently the widget is very homegrown. It works great, but is difficulty to grep and modify. I propose a rewrite into JQuery/Backbone or something to keep the widget code minimal and maintainable.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.