Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6729343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:16:42+00:00 2026-05-26T10:16:42+00:00

Please I need help with this code: >>> t = Transaction.objects.filter(paid=True) >>> t [<Transaction:

  • 0

Please I need help with this code:

>>> t = Transaction.objects.filter(paid=True)
>>> t
[<Transaction: ac0e95f6cd994cc39807d986f7a10d4d>, <Transaction: 7067361871fd459f
aa144988ffa22c7c>, <Transaction: 134e5ab4b0a74b5a985ff53e31370818>, <Transaction
: ef451670efad4995bff755621c162807>]
>>> t[0]
<Transaction: ac0e95f6cd994cc39807d986f7a10d4d>
>>> t[0].branch_name
<Branch: WAREHOUSE ROAD>
>>> Transaction.objects.get(branch_name='WAREHOUSE ROAD')
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "C:\Python27\lib\site-packages\django-1.3-py2.7.egg\django\db\models\mana
ger.py", line 132, in get
    return self.get_query_set().get(*args, **kwargs)
  File "C:\Python27\lib\site-packages\django-1.3-py2.7.egg\django\db\models\quer
y.py", line 344, in get
    num = len(clone)
  File "C:\Python27\lib\site-packages\django-1.3-py2.7.egg\django\db\models\quer
y.py", line 82, in __len__
    self._result_cache = list(self.iterator())
  File "C:\Python27\lib\site-packages\django-1.3-py2.7.egg\django\db\models\quer
y.py", line 273, in iterator
    for row in compiler.results_iter():
  File "C:\Python27\lib\site-packages\django-1.3-py2.7.egg\django\db\models\sql\
compiler.py", line 680, in results_iter
    for rows in self.execute_sql(MULTI):
  File "C:\Python27\lib\site-packages\django-1.3-py2.7.egg\django\db\models\sql\
compiler.py", line 735, in execute_sql
    cursor.execute(sql, params)
  File "C:\Python27\lib\site-packages\django-1.3-py2.7.egg\django\db\backends\ut
il.py", line 34, in execute
    return self.cursor.execute(sql, params)
  File "C:\Python27\lib\site-packages\django-1.3-py2.7.egg\django\db\backends\my
sql\base.py", line 86, in execute
    return self.cursor.execute(query, args)
  File "build\bdist.win32\egg\MySQLdb\cursors.py", line 176, in execute
    if not self._defer_warnings: self._warning_check()
  File "build\bdist.win32\egg\MySQLdb\cursors.py", line 92, in _warning_check
    warn(w[-1], self.Warning, 3)
Warning: Truncated incorrect DOUBLE value: 'WAREHOUSE ROAD'

Here is Branch and Transaction models:

class Branch(models.Model):
    """ Branch """
    bid = models.AutoField(primary_key=True)
    institution = models.CharField(max_length=50)
    branchcode = models.CharField(max_length=50)
    name_branch = models.CharField(max_length=255)
    name_branch_short = models.CharField(max_length=50)
    address_1 = models.CharField(max_length=100)
    name_city = models.CharField(max_length=50)
    name_state = models.CharField(max_length=50)
    sector = models.CharField(max_length=50)

    class Meta:
        db_table = u'branch'

    def __unicode__(self):
        return self.name_branch

class Transaction(models.Model):
    """Gateway transactions"""
    id = models.AutoField(primary_key=True)
    tpin = UUIDField(max_length=32, blank=True, editable=False,\
        help_text='Transaction Payment Identification Number')
    user_id = models.IntegerField(help_text='The user who made the transaction')
    amount = models.DecimalField(max_digits=14, decimal_places=2, \
        help_text='Transaction amount')
    identifier = models.CharField(max_length=100, blank=True, \
        help_text='A unique identifier provided by the student')
    institution = models.ForeignKey(Institution, related_name='transactions')
    financial_institution = models.ForeignKey('FinancialInstitution', blank=True, null=True, related_name='transactions', help_text='The financial institution this transaction was updated in')
    branch_name = models.ForeignKey(Branch, blank=True, null=True, related_name='transactions', \
        help_text='The bank branch where this transaction is originating from')
    paid = models.BooleanField(default=False)
    teller_no = models.CharField(max_length=20, blank=True)
    created = models.DateTimeField(auto_now_add=True)
    updated = models.DateTimeField(auto_now=True)

    audit_log = AuditLog(exclude=['created', 'updated', ])

    def __unicode__(self):
        return self.tpin

    def natural_key(self):
        """ A natural key is a tuple of values that can be used to uniquely identify an object 
        instance without using the primary key value.
        """
        return self.tpin

I tried to serialize Transaction like this:

>>> from django.core import serializers
>>> serializers.serialize('csv', t)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "C:\Python27\lib\site-packages\django-1.3-py2.7.egg\django\core\serialize
rs\__init__.py", line 91, in serialize
    s.serialize(queryset, **options)
  File "C:\Python27\lib\site-packages\django-1.3-py2.7.egg\django\core\serialize
rs\base.py", line 48, in serialize
    self.handle_fk_field(obj, field)
  File "C:\Python27\lib\site-packages\django-1.3-py2.7.egg\django\core\serialize
rs\python.py", line 48, in handle_fk_field
    related = getattr(obj, field.name)
  File "C:\Python27\lib\site-packages\django-1.3-py2.7.egg\django\db\models\fiel
ds\related.py", line 315, in __get__
    rel_obj = QuerySet(self.field.rel.to).using(db).get(**params)
  File "C:\Python27\lib\site-packages\django-1.3-py2.7.egg\django\db\models\quer
y.py", line 349, in get
    % self.model._meta.object_name)
DoesNotExist: Branch matching query does not exist.

I don’t understanding why get is returning DoesNotExists on Branch. I showed an example above which shows that Branch has a record in Transaction.

Looping through t I get a result, but then followed by DoesNotExist: Branch matching query does not exist

>>> for i in t:
...     i.branch_name
...
<Branch: WAREHOUSE ROAD>
Traceback (most recent call last):
  File "<console>", line 2, in <module>
  File "C:\Python27\lib\site-packages\django-1.3-py2.7.egg\django\db\models\fiel
ds\related.py", line 315, in __get__
    rel_obj = QuerySet(self.field.rel.to).using(db).get(**params)
  File "C:\Python27\lib\site-packages\django-1.3-py2.7.egg\django\db\models\quer
y.py", line 349, in get
    % self.model._meta.object_name)
DoesNotExist: Branch matching query does not exist.

Please help. Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:16:43+00:00Added an answer on May 26, 2026 at 10:16 am

    This query:

    Transaction.objects.get(branch_name='WAREHOUSE ROAD')
    

    filters for branch_name which is a ForeignKey field. To query on that name, you should use two underscores:

    Transaction.objects.get(branch_name__name_branch='WAREHOUSE ROAD')
    

    Not the most convenient names for your fields…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some help, PLEASE LOOK AT EDIT 2 This is code of huffman:
I need some help with this, please ... If I save a transaction status
Great Mates... I need your help.. please let me know why this code is
I need some help with a LINQ query in VB.Net, please. I have this
I need help with debugging this piece of code. I know the problem is
Kind of stuck with this thing, that's why need help please. I am using
I need help on this following aspx code aspx Code: <asp:Label ID =lblName runat
i need some help. i have this code: <%= f.datetime_select :date, :start_year => 2011
i need again your help... I have this php code: <? if(isset($_POST['addnews'])){ $type =
I am a newbie with iphone programming. I need some help with this code.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.