i’m using django and sql server database when i try to create point to my model it keep giving me this error
ProgrammingError at /api/common/v1/location/ (‘42000’, “[42000]
[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]No column name
was specified for column 1 of ‘subquery’. (8155) (SQLExecDirectW)”)
this is my model
class Location(TimeStampedWithNamesModel):
"""this class for general Location model."""
district = models.ForeignKey(
District,
on_delete=models.CASCADE,
related_name="district_locations",
null=True,
blank=True,
)
city_id = models.IntegerField(null=True, blank=True)
region_id = models.IntegerField(null=True, blank=True)
country_id = models.IntegerField(null=True, blank=True)
polygon = models.PolygonField(null=True, blank=True)
point = models.PointField(null=True, blank=True)
area = models.FloatField(null=True, blank=True)
is_polygon = models.BooleanField(default=False)
diameter = models.FloatField(null=True, blank=True)
class Meta:
"""this Meta class for the location model."""
ordering = ("-created_at",)
unique_together = UNIQUE_TOGETHER_NAME_WITH_COMPANY
verbose_name = _("Location")
verbose_name_plural = _("Location")
and for my setting
DATABASES = {
"default": {
"ENGINE": config(
"SQL_ENGINE", default="mssql"
),
"NAME": config(
"SQL_DATABASE", default="xxx"
),
"USER": config("SQL_USER", default="admin"),
"PASSWORD": config("SQL_PASSWORD", default="xxxx"),
"HOST": config("SQL_HOST", default="xxxxx"),
"PORT": config("SQL_PORT", default="1433"),
"ATOMIC_REQUESTS": True,
"OPTIONS": {
"driver": "ODBC Driver 17 for SQL Server",
}
},
}
note that another models are work fine I can create and list and update them