﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
29424	Datetime objects parsed as strings when signals used - Django 1.9.5	Adrian Castellanos	nobody	"I found a strange behavior when accesing objects models using signals. The model is declared as:

{{{
class Campaign(models.Model):
    start_stay_date = models.DateTimeField(null=True, blank=True)
    end_stay_date = models.DateTimeField(null=True, blank=True)
}}}

When I use signals to connect the changes of the model with a function, a found that the instance that is passed as argument has strings instead of datetime in the dates:

The code of the conection between the model and the function is:

{{{
def export_campaign_to_mongo(sender, instance, *args, **kwargs):
    check_dates()
post_save.connect(export_campaign_to_mongo, Campaign)
}}}

This is the output of the console checking the types of the objects:

{{{
>>>type(instance)
<class 'campaigns.models.Campaign'>
>>>instance.start_date
'2018-04-11T00:00:00'
>>>from campaigns.models import Campaign
>>>Campaign.objects.first().start_date
datetime.datetime(2016, 10, 10, 0, 0)
}}}

I am using Django v1.9.5. 




"	Bug	new	Uncategorized		Normal		signals model		Unreviewed	0	0	0	0	0	0
