Friday, November 25, 2011

Bulk import of data

Hi everybody!

I have a CSV file and have to import it in my Django website.

Say I have three models involved: category, sub_category and product.

### models.py ###
class Category(models.Model):
name = models.CharField(max_lenth=100)

class SubCategory(models.Model):
name = models.CharField(max_length=100)
parent_category = models.ForeignKey(Category)

class Product(models.Model):
name = models.CharField(max_length=200)
sub_category = models.ForeignKey(SubCategory)
##########


Say this is my CSV file (category, sub_category, product):

### file.csv ###
clothing man;trousers;levis 501
clothing woman;shirt;nice shirt
[...]
##########


I am not sure on which way to go. Do you have any hints or web
references to look at?

Thanks, Fabio.

--
Fabio Natali

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment