Scrapy, a fast high-level web crawling & scraping framework for Python.
Fixed DjangoItem to work properly with auto-generated fields (such as the primary key); it will now ignore those that have had the auto_created flag set - this now allows us to work with custom primary keys as the previous way ignored a custom primary key field. --- scrapy/contrib_exp/djangoitem.py | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-)
Darian Moody05101c7bba2a
diff --git a/scrapy/contrib_exp/djangoitem.py b/scrapy/contrib_exp/djangoitem.pyindex dfef58dac..1abe98bfd 100644--- a/scrapy/contrib_exp/djangoitem.py+++ b/scrapy/contrib_exp/djangoitem.py@@ -11,8 +11,7 @@ class DjangoItemMeta(ItemMeta):cls._model_fields = []cls._model_meta = cls.django_model._metafor model_field in cls._model_meta.fields:- # XXX: for now we're treating each PK as autogenerated field- if model_field != cls._model_meta.pk:+ if model_field.auto_created == False:if model_field.name not in cls.fields:cls.fields[model_field.name] = Field()cls._model_fields.append(model_field.name)@@ -31,4 +30,3 @@ class DjangoItem(Item):if commit:model.save()return model-