def commit_items(self, response_dict): """ Accepts a dict like this: {"items":[{"id":18697,"siteId":8162,"roleId":-1,"name":"Annual Report 2007 ...}],"totalItemsCount":1010,"skip":0,"limit":10} :param response_dict: dict of items :return: """ for item in response_dict['items']: try: p = Page.objects.get(page_id=item.get('id')) except Page.DoesNotExist: p = Page() exp_date = item.get('expiryDate') exp_date = datetime.datetime.strptime( exp_date.split('T')[0], '%Y-%m-%d') p.name = item.get('name') p.url = item.get('pageUrl') p.enabled = item.get('enabled') p.expires = exp_date p.page_id = item.get('id') p.content = item.get('content') p.title = item.get('title') p.template_id = item.get('templateId') p.seo_description = item.get('seoMetadataDescription') p.save()