Django's Date/Time fields on models accepts instances from python's datetime module.
So you need to create one import datetime date = datetime.datetime.strptime(datetime_string, datetime_string_format) model_instance.datecolumn = date model_instance.save() On Wed, Oct 8, 2008 at 3:17 PM, Alfonso <[EMAIL PROTECTED]> wrote: > > Hi, > > I have a textfile full of event data that I'm trying to parse into the > associated postgresql db via django. Wrote a simple load.py script I > can run via shell. Being going well though I've stumbled when > importing DateField and TimeField values. > > the relevant bits of the code that processes the .txt file runs like > this: > > for line in fi: > event = line.split('~') > time = event[7].replace(".", ":") +":00" > > Which gives me a string along lines of "12:00:00" - what I wanted... > > ...but this throws an error against TimeField: > > "ValidationError: Enter a valid time in HH:MM[:ss[.uuuuuu]] format." > > So what do I need to do to the string before it will validate? I have > a feeling its because it is a string being passed, not integer value? > > Any help appreciated! > > Allan > > > -- ------------------------------------------------------ Ales Zoulek +420 604 332 515 Jabber: [EMAIL PROTECTED] ICQ: 82647256 ------------------------------------------------------ --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---