django-rq icon indicating copy to clipboard operation
django-rq copied to clipboard

Unable to call static method within the same class Model

Open ryanermita opened this issue 7 years ago • 2 comments

python version: 2.7 django version: 1.10.6 django-rq version: 0.9.6.

Im unable to call a function inside a class. sample code

class SampleClass(models.Model):
    @staticmethod
     def my_function(data):
         return things

     @property
     def push_function_to_worker(self):
          queue = django_rq.get_queue('high')
          data = {'data': 'things'}
          queue.enqueue(SampleClass.my_function, data)

our work around is defining the function outside the class, which is kinda dirty but it works. Is there any cleaner way to do this. Thank you 👍

def my_function(data):
    return things

class SampleClass(models.Model):
     @property
     def push_function_to_worker(self):
          queue = django_rq.get_queue('high')
          data = {'data': 'things'}
          queue.enqueue(my_function, data)

ryanermita avatar Sep 26 '17 06:09 ryanermita

Did you manage to find a workaround/cleaner way to do this without having to move the function out of the class?

jurecuhalev avatar Dec 11 '17 10:12 jurecuhalev

I think I've got the same issue. But considering that I'm not using django-rq I think it might be an error related to rq in general :(

yunderboy avatar Feb 25 '18 22:02 yunderboy