I\'ve been working with Scrapy but run into a bit of a problem.
DjangoItem
has a save
method to persist items using the Django ORM. This is
for related models with foreignkeys
def update_model(destination, source, commit=True):
pk = destination.pk
source_fields = fields_for_model(source)
for key in source_fields.keys():
setattr(destination, key, getattr(source, key))
setattr(destination, 'pk', pk)
if commit:
destination.save()
return destination