On Mon, Mar 1, 2010 at 2:04 AM, Michael Shafrir <mshaf...@gmail.com> wrote:
> Can a date be loaded into a DateField using Django's loaddata admin
> feature? I have a JSON file that I'm using to bulk load data into my
> app. When you dumpdata, date fields are outputted in the format yyyy-
> mm-dd. However, if you try loading data back in with the same format,
> the field is treated as a string and the load fails.
>
> For example, I have a field authorization_date of type
> models.DateField(). When the value of a field is "2001-12-14", I get
> the following error:
>
>> Warning: Data truncated for column 'authorization_date' at row 1
>
> So how can I load dates using Django's loaddata?

There is something unusual going on here. Django has an extensive unit
test suite that confirms that dates can round-trip through dumpdata
then loaddata. I've never seen an error of the type you describe when
loading dates.

In order to work out what is going on here, we'll need some more information:

 * What database are you using? OS? Python version? DB library version?
 * How did you create your tables? Did you use inspectdb?
 * Have you applied any post-syncdb ALTER statements to your tables?
 * Can you provide a minimal example (e.g., a single model with 1 date
field) that reproduces the problem?

Yours,
Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to