I have a django app that has been working okay and all of a sudden something seems to be broken.
class ClosedUserGroup(models.Model):
""" Preset definitions for ClosedUserGroup:
"""
is_active = models.BooleanField(default=True)
is_deleted = models.BooleanField(default=False)
created_at = models.DateTimeField(
auto_now=True,
auto_now_add=True,
null=True,
default='2013-08-15 13:37:13.370030'
)
name = models.CharField(max_length=256, default='<MISSING:CUG_NAME')
description = models.CharField(max_length=256)
class Partner(models.Model):
id = models.IntegerField(primary_key=True)
is_active = models.BooleanField(default=True)
is_deleted = models.BooleanField(default=False)
created_at = models.DateTimeField(
auto_now=True,
auto_now_add=True,
null=True,
default=datetime.datetime.now()
)
name = models.CharField(max_length=256, default='<MISSING:PARTNERNAME>')
class PartnerCug(models.Model):
""" Partner to ClosedUserGroup relation
"""
is_active = models.BooleanField(default=True)
is_deleted = models.BooleanField(default=False)
created_at = models.DateTimeField(
auto_now=True,
auto_now_add=True,
null=True,
default='2013-08-15 13:37:13.370030'
)
partner = models.ForeignKey(Partner)
cug = models.ForeignKey(ClosedUserGroup)
class Account(models.Model):
"""
Account:
TODO:DESCRIPTION
"""
id = models.IntegerField(primary_key=True)
is_active = models.BooleanField(default=True)
is_deleted = models.BooleanField(default=False)
created_at = models.DateTimeField(
auto_now=True,
auto_now_add=True,
null=True,
default=datetime.datetime.now()
)
number = models.CharField(max_length=64)
submitted_by = models.ForeignKey(
Partner,
db_column='submitted_by'
)
in django shell, the following commands run successfully and returns a result of 1:
from myapp.models import Account
account_object = Account.objects.filter(id=1)
account_object.filter(account__submitted_by__partnercug__cug=3).count()
However, in django itself, I have the function
def get_other_accounts():
"""get total accounts"""
account_object = Account.objects.filter(id=1)
total_accounts = account_object.filter(account__submitted_by__partnercug__cug=3).count()
This however fails with the error DatabaseError: current transaction is aborted, commands ignored until end of transaction block
and it points to the last line in that function. So its working django shell but not from the web app.