1. Dane Springmeyer
  2. django-shapes

Commits

James Rutherford  committed 020bdb2

Allow null foreign keys in export

  • Participants
  • Parent commits 190f7ea
  • Branches default

Comments (0)

Files changed (1)

File shapes/views/export.py

View file
  • Ignore whitespace
             for field in attributes:
                 # if the field is a foreign key, return its pk value. this is
                 # a problem when a model is given a __unicode__ representation.
-                if isinstance(field,ForeignKey):
-                    value = getattr(getattr(item,field.name),'pk')
-                else:
-                    value = getattr(item,field.name)
+                value = getattr(item, field.name)
+                if value is not None and isinstance(field, ForeignKey):
+                    value = getattr(attr, 'pk')
+
                 # truncate the field name.
                 # TODO: handle nonunique truncated field names.
                 feat.SetField(str(field.name[0:10]),value)