Opened 10 years ago

Closed 10 years ago

#330 closed defect (invalid)

get_relatedobject_count error with OneToOneFields

Reported by: davidschein@… Owned by: adrian
Component: Metasystem Version:
Severity: normal Keywords:
Cc: wojtek@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


I have to use ForeignKey instead of OneToOneField lest I receive the following traceback when going to the detail for my object:
There's been an error:

Traceback (most recent call last):

File "C:\django\django\core\handlers\", line 62, in get_response

return callback(request, param_dict)

File "C:\django\django\views\admin\", line 855, in change_stage

manipulator = mod.ChangeManipulator(object_id)

File "C:\django\django\utils\", line 3, in _curried

return args[0](*(args[1:]+moreargs), dict(kwargs.items() + morekwargs.items()))

File "C:\django\django\core\meta\", line 1368, in manipulator_init

count = getattr(self.original_object, 'get_%s_count' % opts.get_rel_object_method_name(rel_opts, rel_field))()

AttributeError: 'Participant' object has no attribute 'get_individual_count'

My model looks like:
from django.core import meta

class Participant(meta.Model):

fields = (

meta.PositiveIntegerField('auction_number', blank=False, null=False, unique=True),
meta.CharField('address_1', maxlength=50, blank=True),
meta.CharField('address_2', maxlength=50, blank=True),
meta.CharField('city', maxlength=30, blank=True),
meta.USStateField('state', blank=True),
meta.CharField('zip', maxlength=9, blank=True),
meta.PhoneNumberField('phone', blank=True),


def repr(self):

return "%s" % (

class Individual(meta.Model):

fields = (

meta.OneToOneField(Participant, edit_inline=meta.TABULAR, num_in_admin=1),
meta.CharField('first_name', 'First', maxlength=25, core=True),
meta.CharField('last_name', 'Last', maxlength=25, core=True),


def repr(self):

return "%s %s" % (self.first_name, self.last_name)

Change History (1)

comment:1 Changed 10 years ago by maurycypw@…

  • Cc wojtek@… added
  • Component changed from Admin interface to Metasystem
  • Resolution set to invalid
  • Status changed from new to closed
  • Summary changed from get_%s_count error with OnToOneFields to get_relatedobject_count error with OneToOneFields

As documentation points, there's no get_relatedobject_count() with One-to-one relation.

This idea does not make any sense. Method get_count() returns number of objects matched by the lookup. In the OneToOneField case, it would always return one.

If I'm wrong, please reopen the ticket.

Note: See TracTickets for help on using tickets.
Back to Top