filter()
returns a QuerySet (basically, a list of model instances). And, since there is no get_stubbed_time
attribute on a QuerySet
- you are getting AttributeError
while trying to get get_stubbed_time
attribute from a queryset. And, because of you are not running in the DEBUG mode - you are seeing 500.
You need to use get() instead:
transaction = Transaction.objects.get(id=id)
print(transaction.get_stubbed_time)
Also, keep DEBUG=True
in development - it helps a lot to quickly understand the root cause of errors. But, don't forget to turn it off in production.
Hope that helps.