PaulGilmartin / django-pgpubsub

A distributed task processing framework for Django built on top of the Postgres NOTIFY/LISTEN protocol.
Other
245 stars 12 forks source link

Trigger-based channels cannot deserialize models containing geometric fields #58

Open a4f8b807445a4622 opened 1 year ago

a4f8b807445a4622 commented 1 year ago

Setting up a trigger-based channel with a model containing a geometric field type returns a serialization error.

TypeError: Cannot set Location SpatialProxy (POINT) with value of type: <class 'dict'>

from dataclasses import dataclass
from django.contrib.gis.db.models import PointField
from django.db import models
from pgpubsub.channel import TriggerChannel

# models.py
class Location(models.Model):
    name = models.CharField(max_length=255)
    point = PointField(srid=4326)

# channels.py
@dataclass
class LocationTriggerChannel(TriggerChannel):
    model = Location
    lock_notifications = True
PaulGilmartin commented 1 year ago

@a4f8b807445a4622 Thanks for raising. I'm hoping to have time to take a look at existing issues this month at some point. Hopefully I will be able to get this into the next release.