I'm rewriting an app with django (my first django app) and was hoping to import data into my newly created models. I have modified the schema slightly so I'm querying my old database and formatting data but I'm unsure how to proceed for import into Django.
so far I'm querying the old db direclty with MySQLdb and getting my data which looks something like this: [513L, '2009-02-17 16:56:57', 23L, 1L, 1L, '2009-02-17 16:56:48', '2009-02-17 16:56:57', 9L] I am mapping those values into a dictionary with the new field names as keys it looks something like this: {'node': 2, 'status': 1, 'loc_id': 22, 'time_difference': 12, 'time_end': '2009-02-15 23:33:45', 'time_start': '2009-02-15 23:33:33', 'log_time': '2009-02-15 23:33:45'} my new model looks like this (I'm not clear here on the syntax to reference to a ForeignKey on another app/model) : class DeviceFloormatSummary(models.Model): loc_id = models.ForeignKey("server.Location") node = models.ManyToManyField("server.Node") status = models.BooleanField(db_index=True) log_time = models.DateTimeField() time_start = models.DateTimeField() time_end = models.DateTimeField() time_difference = models.IntegerField(db_index=True) what I'm doing next is loop through my results to insert into db. r = data_collected[1] (a dict like the one above) d = DeviceFloormatSummary(r) d.save() this is not working, I think the main issue is what my Django model expects me to pass him to save. The error on stacktrace reads: TypeError: isinstance() arg 2 must be a class, type, or tuple of classes and types any help much appreciated, --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---