Opened 53 minutes ago
Last modified 26 minutes ago
#37324 assigned New feature
Cannot assign expressions to spatial fields
| Reported by: | Jacob Walls | Owned by: | Md. Saikat Islam |
|---|---|---|---|
| Component: | GIS | Version: | dev |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
SpatialProxy is too strict in the types it allows to be assigned to spatial fields -- it should allow expressions (if it can be implemented simply enough).
See fiddle:
from django.contrib.gis.db.models import PointField from django.db import models class Employee(models.Model): home = PointField() work = PointField() def run(): instance = Employee.objects.create( home="POINT(1 1)", work="POINT(2 2)" ) # Work from home. instance.work = models.F("home") instance.save()
File "/usr/local/lib/python3.12/site-packages/django/contrib/gis/db/models/proxy.py", line 82, in __set__ raise TypeError( TypeError: Cannot set Employee SpatialProxy (POINT) with value of type: <class 'django.db.models.expressions.F'>
Marking new feature, as we should document that we added support.
Change History (3)
comment:1 by , 27 minutes ago
comment:2 by , 26 minutes ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:3 by , 26 minutes ago
| Owner: | set to |
|---|---|
| Status: | new → assigned |
Note:
See TracTickets
for help on using tickets.
I was able to reproduce the reported
TypeErrorwithF("home")assigned to aPointField. I'll work on a fix to allow expressions to be assigned to spatial fields.