1👍
This is not how you use a manager. Even with a perfectly normal class instance, your attempt wouldn’t give you what you wanted: you would need to instantiate it and call get_fee()
on the instance.
With a manager, you don’t need to instantiate it, because that’s already done for you as the objects
attribute on the model. But you still need to call the relevant method:
cd.amount = Sample.objects.get_fee()
However, this still won’t work. That’s because you’ve referred to self.myItemId
and self.myItemType
, which don’t exist on the Manager object. Which leads me to the conclusion that you don’t want a Manager object at all: you just want a standard model method. And there’s no need for the raw SQL, either: your code is perfectly easily expressed using normal model query syntax.
(I can’t show you exactly what it would look like, because the ForeignKeys in your example don’t make any sense, and it’s not clear where fee
is supposed to be coming from.)