Reputation: 1586
I can't seem to access a function within my model manager.
models.py
class ChargeManager(models.Manager):
def dorefundcharge(self, charge_id):
print(charge_id)
class Charge(models.Model):
charge_id = models.CharField(max_length=120)
objects = ChargeManager()
views.py
charge_id = 1234
refund_of_charge = charge.dorefundcharge(charge_id)
Error
AttributeError at /accounts/profile/refundcharge/540/
'Charge' object has no attribute 'dorefundcharge'
Upvotes: 0
Views: 19
Reputation: 4630
We need to use:
Charge.objects.dorefundcharge(charge_id)
For more details, check this example in Django's official documentation.
Upvotes: 1