DavidA wrote:
> First, to use the model from a script I had to set the
> DJANGO_SETTINGS_MODULE environment variable and add the base directory
> to sys.path. I've seen this before so I guess this is just the way it
> is but it would be nice not to have dependencies on environment
> variables. Is there a different way to do this?

You can set the environment variable at the top of your scripts by 
importing the Python os module, just like you can import sys and set 
sys.path.

> Finally, for dates I had to manually convert them because they weren't
> in the yyyy-mm-dd format required by DateField.html2python. It seems a
> bit limited to only support one date format in DateField but I guess
> that avoids the ambiguities with date formats. Since my model's fields
> are the same names as the column headings in the flat files, now I can
> map all the conversions automatically without doing anything
> field-specific, *except* for date fields. Any suggestions?

The Python datetime and time modules are huge resources.  In this case 
you want time.strptime() to parse an arbitrary time format into a tuple 
and then you can use that tuple to create a datetime.date object which 
you can directly assign to the DateField.

-- 
--Max Battcher--
http://www.worldmaker.net/
"I'm gonna win, trust in me / I have come to save this world / and in 
the end I'll get the grrrl!" --Machinae Supremacy, Hero (Promo Track)

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to