Package to get data from given source and put it into existing Django models. Example app contains RSS related models. If you feed RSS XML file to this program then it would put found elements into corresponding models. Program automatically discovers all models in target project and chooses most appropriate of them.
Optionally create and activate virtual environment:
virtualenv -p python3 .venv
source .venv/bin/activateInstall dependencies and test tools:
pip install -r requirements.txtCreate local settings for example project:
cp example_project/settings/local.py.example example_project/settings/local.py
vim example_project/settings/local.pyNow you may run tests and see test coverage:
pytestInstall this package into your site-packages:
pip install -e .After installation you may remove (or move) data_mapper directory.
Example project will work and have access to management commands:
rm -rf data_mapper
./manage.py import_xml --helpTo use data mappers in your Django project you should just add 'data_mapper'
into settings, INSTALLED_APPS section.
From command line:
./manage.py import_xml path/to/rss-feed.xmlFrom python code:
from data_mapper import XmlMapper
xml_mapper = XmlMapper(open('path/to/rss-feed.xml'))
xml_mapper.import_data()