On 12 Jul 2011 01:22, "Lachlan Musicman" <data...@gmail.com> wrote: > > On Mon, Jul 11, 2011 at 21:02, stan <stanislas.gue...@gmail.com> wrote: > >> > >> > class Book(models.Model): > >> > title = models.CharField(max_length=120) > >> > date_published = models.DateField() > >> > >> Big tip - if you *actually* need a date_published field, use a string :) > > > > Sorry, but I don't get it. > > > > You mean a CharField, right ? > > Yah, sorry. I actually needed to write a "Books" app for some > translation data entry that needed doing at my local Uni - and Char > was plain easier for search and sort than Date - and very few books > have the month/day details - think about what you actually need the > date_published field for: search and sort and that's about it. You do > not need to do any maths with it. Use the Char.
Why would you use a CharField for a date column? This is extremely bad practise. You'd just simply use a DateField, then default to the 'first available value' for missing fields in the date. For exampme, June 2010 would become 2011/06/01 00:00:00. Unless you have a good reason not to use datefield..? > > cheers > L. > > > -- > Schweigt stille, plaudert nicht (Be still, stop chattering) (aka The > Coffee Cantata) (BWV 211) is a secular cantatawritten by Johann > Sebastian Bach between 1732 and 1734. In a satirical commentary, the > cantata tells of an addiction to coffee, a pressing social problem in > eighteenth century Leipzig, where this work was premiered. (via > http://bestofwikipedia.tumblr.com/ ) > > -- > You received this message because you are subscribed to the Google Groups "Django developers" group. > To post to this group, send email to django-developers@googlegroups.com. > To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/django-developers?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.