Django Postgresql Sum Error
<p>I have a model Transaction 
model.py</p>

<pre><code>class TransactionManager(models.Manager):
def get_queryset(self):
    return TransactionQuerySet(self.model, using=self._db)


def all_for_user(self, user):
    # self.get_queryset().mark_all_unread(user)
    return self.get_queryset().get_user(user)


  class Transaction(models.Model):
reason = (
    ("Fund Transfer","Fund Transfer"),
    ("Fund Recieved","Fund Recieved"),
    )

recipient_username = models.CharField(max_length=100)
sender = models.CharField(max_length=100)
recipient_name = models.CharField(max_length=50)
purpose = models.CharField(max_length=100, choices=reason)
amount = models.DecimalField(decimal_places=2, max_digits=20)
transaction_charge = models.DecimalField(decimal_places=2, max_digits=20)
message = models.CharField(max_length=255)
# total_balance = models.DecimalField(decimal_places=2, max_digits=200, null=True, blank=True)
timestamp = models.DateTimeField(auto_now=False, auto_now_add=True)

objects = TransactionManager()

def __str__(self):
    return self.recipient_name
</code></pre>

<p>and view.py </p>

<pre><code>def useraccount(request):
# if not request.user.is_authenticated:
#   raise Http404

name = request.user

# account = get_object_or_404(Transaction, recipient_username=name)
notification = Notification.objects.all_for_user(name)
trans = Transaction.objects.all_for_user(name)
transaction = Transaction.objects.all().filter(recipient_username=request.user).first()
user1 = Profile.objects.get(user= name)
# trans = Transaction.objects.aggregate(Sum('amount'))
# total1 = 
total = trans.aggregate(price_sum=Sum('amount'))
# total = trans.aggregate(price_sum=Sum(Decimal('amount'))
# total = Decimal(total)
total_price = Decimal(total['price_sum'])
# account.total_balance=total_price
# account.save()
# tra = Transaction.annotate(total=DistinctSum('amount')

context = {
"notification" :notification,
# "account" : account,
"user1" : user1,
"total_price" :total_price,
# "tra":tra,
# "total":total,

}

return render(request, "notification/account.html", context)
</code></pre>

<p>Now here is the problem.
I have this Error when i use PostgreSQL</p>

<pre><code>ProgrammingError at /notification/useraccount/
function sum(character varying) does not exist
LINE 1: SELECT SUM("notification_transaction"."amount") AS "price_su...
               ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
Request Method: GET
Request URL:    http://myproject.com/notification/useraccount/
Django Version: 1.8.6
Exception Type: ProgrammingError
Exception Value:    
function sum(character varying) does not exist
LINE 1: SELECT SUM("notification_transaction"."amount") AS "price_su...
               ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
Exception Location: /home/okrie/lib/python3.4/django/db/backends/utils.py in execute, line 64
Python Executable:  /usr/local/bin/python3
Python Version: 3.4.4
Python Path:    
['/home/okrie/webapps/pyproject',
 '/home/okrie/webapps/pyproject/accountant',
 '/home/okrie/webapps/pyproject/lib/python3.4',
 '/home/okrie/lib/python3.4/pip-8.1.2-py3.4.egg',
 '/home/okrie/lib/python3.4',
 '/usr/local/lib/python34.zip',
 '/usr/local/lib/python3.4',
 '/usr/local/lib/python3.4/plat-linux',
 '/usr/local/lib/python3.4/lib-dynload',
 '/usr/local/lib/python3.4/site-packages']
</code></pre>

<p>but this works well on sqlite3. I don't have this error
with sqlite3 but when i use PostgreSQL i have the above
error</p>

<p>Could anybody point out what ways i can sum up values in PostgreSQL
and Django and resolving this problem</p>