I would like to make a query in Django that use a function that take parameters from db e from python program. The function is shown below:
> def myFunc(a, b):
> val = mathematical expression with a and b
> return val
I would like that:
- a comes from myTable (represent the field 'num')
- b comes from python Code
class myTable(models.Model): num = models.IntegerField(default=0)
I would like to do a query similar to this in views.py:
b = 4 #it must be variable
c = 10 #it must be variable
myTable.objects.all().extra(select = {'new_param' : myFunc(num , b)}, where = ['new_param > %d'], params = [c])
How can I do that?
myFunc?