  
          try:
              data = self.to_python(data)
              initial = self.to_python(initial)
          except ValidationError:
              return True
  
          # Only do a geographic comparison if both values are available
          if initial and data:
              data.transform(initial.srid)
 
</s> remove                 except ImproperlyConfigured as e:
 </s> add                 except ImproperlyConfigured: </s> remove             backend_cls = import_by_path(backend)
 </s> add             import_by_path(backend) </s> remove         err = self.errors
 </s> add         # This triggers a full clean.
        self.errors </s> remove         from django.conf import settings

 </s> add  </s> remove         match = None
 </s> add 
        except forms.ValidationError:
  
          try:
              data = self.to_python(data)
              initial = self.to_python(initial)
        except forms.ValidationError:
              return True
  
          # Only do a geographic comparison if both values are available
          if initial and data:
              data.transform(initial.srid)
keep keep keep keep replace keep keep keep keep keep
 Fixed a number of flake8 errors -- particularly around unused imports and local variables 
django/contrib/gis/forms/fields.py