Re: How to represent a calendar month as a field in django models

2015-05-12 Thread Matthys Kroon
Hi, I ended up creating a custom field ( https://github.com/clearspark/django-monthfield). I used a lot of your input, thank you all. Cheers, Matthys On Mon, May 4, 2015 at 7:09 PM, Tim Chase wrote: > On 2015-05-03 14:35, Matthys wrote: > > I posted the question also on stackoverflow: > > >

Re: How to represent a calendar month as a field in django models

2015-05-04 Thread Tim Chase
On 2015-05-03 14:35, Matthys wrote: > I posted the question also on stackoverflow: > > http://stackoverflow.com/questions/30017229/how-to-represent-month-as-field-on-django-model > > The question is for situations where a model instance relates to a > specific month, but not to a specific day. I

Re: How to represent a calendar month as a field in django models

2015-05-04 Thread Matthys Kroon
Hi Erik, Thanks for your reply. I'm aware of the problems with timedelta(months=2), since the length of a month is not fixed, a length of time specified in months is ambiguous. Though months do have an internally consistent algebra as you point out and people often refer to time-periods in month

Re: How to represent a calendar month as a field in django models

2015-05-04 Thread Erik Cederstrand
> Den 04/05/2015 kl. 14.21 skrev Erik Cederstrand : > > class Month(models.Model): >year = models.IntegerField() >month = models.PositiveSmallIntegerField() > >def add_months(self, n): >assert n >= 0 >dy, dm = divmod(self.month + n, 12) >self.year += dy >

Re: How to represent a calendar month as a field in django models

2015-05-04 Thread Erik Cederstrand
> Den 04/05/2015 kl. 13.26 skrev Matthys Kroon : > > I'm specifically looking at only situations where the year and month alone > are significant. > > The downside I see with using a DateField and forcing the day to the first of > the month, with custom widget etc. is that somebody looking at

Re: How to represent a calendar month as a field in django models

2015-05-04 Thread Matthys Kroon
Hi, I'm specifically looking at only situations where the year and month alone are significant. The downside I see with using a DateField and forcing the day to the first of the month, with custom widget etc. is that somebody looking at the database may not realize that something unusual is going

Re: How to represent a calendar month as a field in django models

2015-05-03 Thread Mike Dewhirst
On 4/05/2015 12:31 PM, Tom Lockhart wrote: Surely that would destroy data which wouldn’t be desirable. I’m not sure how that follows. If you are adjusting a date from whatever it actually is to the first of the month you lose the actual date. Although the question does not state it exp

Re: How to represent a calendar month as a field in django models

2015-05-03 Thread Tom Lockhart
On May 3, 2015, at 7:17 PM, Mike Dewhirst wrote: > On 4/05/2015 11:41 AM, Tom Lockhart wrote: >> On May 3, 2015, at 2:35 PM, Matthys wrote: >> >>> I posted the question also on stackoverflow: >>> >>> http://stackoverflow.com/questions/30017229/how-to-represent-month-as-field-on-django-model >>

Re: How to represent a calendar month as a field in django models

2015-05-03 Thread Mike Dewhirst
On 4/05/2015 11:41 AM, Tom Lockhart wrote: On May 3, 2015, at 2:35 PM, Matthys wrote: I posted the question also on stackoverflow: http://stackoverflow.com/questions/30017229/how-to-represent-month-as-field-on-django-model The question is for situations where a model instance relates to a sp

Re: How to represent a calendar month as a field in django models

2015-05-03 Thread Tom Lockhart
On May 3, 2015, at 2:35 PM, Matthys wrote: > I posted the question also on stackoverflow: > > http://stackoverflow.com/questions/30017229/how-to-represent-month-as-field-on-django-model > > The question is for situations where a model instance relates to a specific > month, but not to a specif

How to represent a calendar month as a field in django models

2015-05-03 Thread Matthys
I posted the question also on stackoverflow: http://stackoverflow.com/questions/30017229/how-to-represent-month-as-field-on-django-model The question is for situations where a model instance relates to a specific month, but not to a specific day. -- You received this message because you are su