I am writing a back end for a mobile application using Django 1.8. django-push-notificationslib provides a model GCMDevice. The problem is that I already have a model Devicewith some required field and some logic that I do not want to lose.
What I wanted to do was inherit entire functions GCMDeviceand configure them on my device model (which btw inherits another mixin that provides spatial data fields, with a custom set of object manager that I want to save). I read about 3 different ideas for django model inheritance, but none of them seemed to solve my problem (supporting managers, providing functionality django-push-notifications, keeping my model fields Device). Maybe OneToOne will do the job?
IDEA:
class Device(MyMixin):
gcm_device = models.OneToOneField(GCMDevice)
my_other_field = models.TextField()
def send_message(self, payload):
self.gcm_device.send_message(payload)
source
share