class Test(models.Model): datum = models.DateTimeField() text = models.CharField(max_length=255)
class TestForm(ModelForm): class Meta: model = Test Rendering the form with form = TestForm(initial={'datum':datetime.datetime(2012, 8, 21, 18, 0, tzinfo=<UTC>)) looks all good. Django translates UTC to my local timezone so everything is displayed correctly. Now here is my problem: wenn I try to validate the form with nothing changed using: form = TestForm(request.POST, initial={'datum':datetime.datetime(2012, 8, 21, 18, 0, tzinfo=<UTC>), }) it failes because django treats the datum as changed. By analysing the form I found the following: is_bound': True, 'cleaned_data': {'datum': datetime.datetime(2012, 8, 21, 20, 0, tzinfo=<DstTzInfo 'Europe/Berlin' CEST+2:00:00 DST>), 'text': u'',}, '_changed_data': ['datum'], '_validate_unique': True, 'initial': {'datum': datetime.datetime(2012, 8, 21, 18, 0, tzinfo=<UTC>)} So django trys to add a new object to the database because the form validates True. But it is treated as bound with the only field changed is 'datum'. This failes of course because text is empty. If I use initial with the CharField set this does not happen and django treats the form as empty and so does nothing. So is there a bug comparing these two date objects, one with tzinfo='Europe/Berlin' and one with tzinfo=<UTC>? Or do I miss something anywhere? I have USE_TZ=True and also have pytz installed. -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/1XmYNjTMjRcJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.