I ran into what I think might be a bug and wanted to check here before possibly posting it.
Essentially what seems to be happening is that Django seems to return datetime.datetime or datetime.date from DateFields in models and I can't figure out why it returns one type at one time and another type at another. I have two models and the parent has a method that is suppose to compare it's latest update date and the date of the latest child update and return whichever date is more rescent. However when I try to unit test the Release.all_last_update method I get the following error: "TypeError: can't compare datetime.datetime to datetime.date" But all values are being pulled from a DateField. Is Django casting it incorrectly or am I missing something somewhere? Models are below. class Release(models.Model): created_on = models.DateField(auto_now=False, auto_now_add=True) last_updated = models.DateField(auto_now=True, auto_now_add=True) def all_last_updated(self): d = [] d.append(self.last_updated) d.append(Activity.objects.filter(release_fk=self).latest ().last_updated) d.sort().reverse() return d[0] class Meta: get_latest_by = 'last_updated' ordering = ["project_fk", "internal_priority"] class Activity(models.Model): created_on = models.DateField(auto_now=False, auto_now_add=True) last_updated = models.DateField(auto_now=True, auto_now_add=True) def all_last_updated(self): return self.last_updated class Meta: get_latest_by = 'created_on' ordering = ['created_on'] --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. 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 -~----------~----~----~----~------~----~------~--~---