-
Notifications
You must be signed in to change notification settings - Fork 10
Doesn't work if model field name is different from db column name #25
Copy link
Copy link
Open
Description
Problem description
I have unmanaged model with geometry that I want to serve as MVT. Problem is that field name differs from table name.
class Obec(models.Model):
id = models.IntegerField(db_column="kod", primary_key=True)
name = models.CharField(max_length=255, db_column="nazev")
geom = models.MultiPolygonField(srid=5514)
okres_code = models.IntegerField(db_column="okres_kod")
class Meta:
managed = False
db_table = "g_obec_p"
I found that djangorestframework-mvt collects non geom columns and then in method _create_select_statement() calls self.only(*columns).query.sql_with_params()
And that's the problem. QuerySet method only works with fields not columns.
So in my case it ends with error:
raise FieldDoesNotExist("%s has no field named '%s'" % (self.object_name, field_name))
django.core.exceptions.FieldDoesNotExist: Obec has no field named 'orp_kod'
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels