- Put CSVTOOL_MODELS in settings.py
- Put csvtool.py somewhere in your project. I like utils/csvtool.py
- Then in a view initiate the uploader with an app.model string
Add something like this to your settings.py
CSVTOOL_MODELS = {'app1.Model1':{'duplicate_entry':'overwrite'},
'app2.Model1':{'duplicate_entry':'overwrite'},
'app2.Model2':{'duplicate_entry':'add'},
'app3.Model1':{'duplicate_entry':'ignore'},
}
Duplicate entries are entry that have have the same primary key value in both the file and the database table. There are three options to deal with duplicate entries.
- ignore
- add
- overwrite
These options are specitfied in CSVTOOL_MODELS in settings.py