Hi,

Using a form did the trick, I did however have a issue with datetime
formats. It appears the formats I got from the string values are not
recognized.

This sorted me out with that:
       from dateutil import parser

        if str(Customer._meta.get_field("pastel_"+col).get_internal_type())
== "DateTimeField":
            try:
                row_form_ready["pastel_"+col] = parser.parse(row[col])
            except:
                row_form_ready["pastel_"+col] = "0000-00-00 00:00:00"


-- Mike



On 11 May 2012 13:54, Tom Evans <tevans...@googlemail.com> wrote:

> On Fri, May 11, 2012 at 12:39 PM, Michael da Silva Pereira
> <mich...@tradepage.co.za> wrote:
> >
> > Hi,
> >
> > Looking for some ideas around a type / conversion matching
> > issue I'm having with a big django model.
> > The model has tons of variables, and all being of different types
> > (int, nullbool, date, datetime, string).
> >
> > I'm trying to pass data from a different database into the django
> > model, but the other DB passes the info to me as string.
> >
> > I don't really want to do type conversions for each and every field,
> > there are around 180 odd. Is there not some sort of function that be
> > used to automatically for the conversion?
> >
> > Any ideas?
> >
> > -- Mike
> >
>
> Could you access the 'other' database via a django model (an unmanaged
> model probably)?
>
> Models themselves will happily accept string data, eg a DateField
> would happily accept the string "2012-01-12.
>
> Alternately, could you transform the values extracted from the other
> database into a query string? If so, you could use a form to process
> the data, as turning arbitrary string fields into model fields is what
> model forms are designed to do.
>
> Cheers
>
> Tom
>
> --
> 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
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 

*
*
*Tradepage, now part of the Cloud Group, is an Authorised Google Apps for 
Business Reseller.  For only R450 per user per year, get Business Email, 
Calendars, Documents, syncing with mobile devices and much more. Find out 
more: http://www.tradepage.co.za/google-apps-for-business*


This email and all contents are subject to the following disclaimer:
http://www.tradepage.co.za/disclaimer

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