1π
β
You can create a custom function using Expressions.
class GeoX(Func):
function = 'X'
MyModel.objects.annotate(x=GeoX('field'))
This will result in the geometry X function being invoked and itβs result being annotated to a field labeled x in your model. However this is the inferior solution. The better solution is to install geodjango. That provides full access to almost every single function in PostGIS. Also works with spatialite and msyql spatial extensions.
π€e4c5
- [Answered ]-Page not found is showing (django)
- [Answered ]-Django: assert 'Many-to-many' relation exists in test
- [Answered ]-How to integrate Django form with Ajax?
- [Answered ]-OneToOneField is not working django
Source:stackexchange.com