[Fixed]-Updating SQL Server table with GEOGRAPHY column in Django

1👍

I ending up changing the SET options in the model’s save method and this is working for now.

class MyModel(models.Model):
    # Model fields here
    def save(self, force_insert=False, force_update=False, using=None,
         update_fields=None):

        cursor = connections['sql_server'].cursor()
        cursor.execute("""SET ANSI_NULLS ON
        SET QUOTED_IDENTIFIER ON
        SET CONCAT_NULL_YIELDS_NULL ON
        SET ANSI_WARNINGS ON
        SET ANSI_PADDING ON""")
        cursor.close()

        super(MyModel, self).save(force_insert, force_update, using, update_fields)
👤duffn

Leave a comment