Weird date math bug?

2017-08-31 Thread Lachlan Musicman
Is there a weird date math bug in Django 1.11.4? I say weird because surely not? I can't see any tickets in the tracker, but I'm definitely seeing it in production. Using postgresql: class Patient(models.Model): -- "The antidote to apocalypticism is *apocalyptic civic

Re: Weird date math bug?

2017-08-31 Thread Lachlan Musicman
Sorry, let me start again: Is there a weird date math bug in Django 1.11.4? I say weird because surely not? I can't see any tickets in the tracker, but I'm definitely seeing it in production. Using postgresql: models.py class ChemoType(models.Model): name = models.CharField(

Re: Weird date math bug?

2017-08-31 Thread James Schneider
On Aug 31, 2017 9:44 PM, "Lachlan Musicman" wrote: Sorry, let me start again: Yay, I'm not the only one that does it! Lol... class ChemoRegime(models.Model): patient = models.ForeignKey(Patient, on_delete=models.CASCADE) chemotype = models.ForeignKey(ChemoType, on_delete=models.CAS

Re: Weird date math bug?

2017-08-31 Thread Lachlan Musicman
On 1 September 2017 at 14:57, James Schneider wrote: > I'm guessing that ChemoRegime.regime_age() contains line 95. > > ChemoRegime defines the stop_date field with null=True and blank=True. I'm > guessing this is because patients may not have yet stopped treatment, so > they have no stop_date. >

Re: Weird date math bug?

2017-08-31 Thread James Schneider
> I am so embarrassed. Thank you James, spot on. cheers L. No worries. I've stuck my foot in my mouth more than once on this list. -James -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails

Re: Weird date math bug?

2017-08-31 Thread Melvyn Sopacua
A few tips on your code: def get_latest_chemo(self): chemo = ChemoRegime.objects.filter(patient=self).latest('stop_date') class ChemoRegime(models.Model): patient = models.ForeignKey(Patient, on_delete=models.CASCADE) Use the related manager here. To make it readable, use

Re: Weird date math bug?

2017-08-31 Thread James Schneider
Also, if you are developing this application for use within the USA, be sure that you are not capturing or storing data that would fall under the HIPAA definition of personal medical data. If it does, your legal compliance responsibilities and liabilities will skyrocket. I'm not a lawyer, so I can

Re: Weird date math bug?

2017-09-01 Thread Lachlan Musicman
On 1 September 2017 at 16:37, James Schneider wrote: > Also, if you are developing this application for use within the USA, be > sure that you are not capturing or storing data that would fall under the > HIPAA definition of personal medical data. If it does, your legal > compliance responsibilit

Re: Weird date math bug?

2017-09-03 Thread Lachlan Musicman
On 1 September 2017 at 16:13, Melvyn Sopacua wrote: > A few tips on your code: > > def get_latest_chemo(self): > chemo = ChemoRegime.objects.filter(pat > ient=self).latest('stop_date') > > class ChemoRegime(models.Model): > patient = models.ForeignKey(Patient, on_delete=mo