I have a Django model that looks like this:
class LocationMaster(models.Model):
id = models.AutoField(primary_key=True)
open_date = models.DateField(blank=True, null=True)
months_open = models.DecimalField(max_digits=18, decimal_places=2, blank=True, null=True) # Calculated column in SQL Server
maturity = models.CharField(max_length=50, blank=True) # Calculated column in SQL Server
def save(self, force_insert=False, force_update=False, using=None, update_fields=None):
# ?? Something here
super(LocationMaster, self).save(force_insert, force_update, using, update_field)
Two of my columns are SQL Server computed columns. I would like to display these columns in my application, including in the admin, but not insert or update these columns since they are computed. Without modified my model, I get this error:
('42000', '[42000] [FreeTDS][SQL Server]The column "months_open" cannot be modified because it is either a computed column or is the result of a UNION operator. (271) (SQLExecDirectW)')
How do I modify my model so that Django does not attempt to insert or update these specific columns?