mirror of
https://github.com/scrapy/scrapy.git
synced 2025-02-26 19:43:40 +00:00
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(-)
This commit is contained in:
parent
37830da1f6
commit
05101c7bba
@ -11,8 +11,7 @@ class DjangoItemMeta(ItemMeta):
|
||||
cls._model_fields = []
|
||||
cls._model_meta = cls.django_model._meta
|
||||
for 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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user