Re: MultipleObjectsReturned with get() on 1.0-beta1 admin UI

2008-08-25 Thread dchandek

OK, this is interesting: I didn't mention that I also has
limit_choices_to set on the self-referential foreign key. When I
remove limit_choices_to the problem goes away! My model is listed
below. I had set limit_choices_to=PARENT_CHOICES on OrgUnit.parent.

[start code]
LIBRARY_ID = 1
SAP_ORG_UNITS = (string, string, ...)

class OrgUnit(models.Model):

DEFAULT_HEAD_TITLE = 'Head' # Default value for OrgUnit head_title
property
# Library `departments' are children of `administrative units',
which are
# children of the top-level org unit.
PARENT_CHOICES = models.Q(is_admin_unit=True) |
models.Q(id=LIBRARY_ID)
SAPORGUNIT_CHOICES = ((s, s) for s in SAP_ORG_UNITS)

name = models.CharField(max_length=255, unique=True)
description  = models.CharField(max_length=255, blank=True,
null=True)
sap_org_unit = models.CharField(max_length=20, blank=True,
null=True,
choices=SAPORGUNIT_CHOICES)
parent   = models.ForeignKey('self', null=True,
blank=True,
 related_name='children')
head = models.ForeignKey(Person, blank=True,
null=True,
 related_name='head_of')
head_title   = models.CharField(max_length=255,
default=DEFAULT_HEAD_TITLE, blank=True)
members  = models.ManyToManyField(Person, null=True,
blank=True,
 
related_name='member_of')
is_admin_unit= models.BooleanField(default=False, null=True,
editable=False)
# Contact Info
campus_box   = models.CharField(max_length=255, blank=True,
null=True)
physical_address = models.CharField(max_length=255, blank=True,
null=True)
email= models.EmailField(blank=True, null=True)
fax  = models.CharField(max_length=40, blank=True,
null=True)
phone= models.CharField(max_length=40, blank=True,
null=True)
phone2   = models.CharField(max_length=40, blank=True,
null=True)
url  = models.URLField(blank=True, null=True)
[end code]

Hope that help ...

Thanks,
David

> This is going to be infinitely easier to debug if have a small example
> model that reliably demonstrates the problem. At the moment, the single
> traceback is not really enough information to go on.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: MultipleObjectsReturned with get() on 1.0-beta1 admin UI

2008-08-25 Thread Malcolm Tredinnick


On Mon, 2008-08-25 at 17:44 -0700, dchandek wrote:
> To make this even stranger, the problem only occurs when the pk of the
> selected (self-)related object is 1. There's something deep going on
> in Django that I can't trace ...

This is going to be infinitely easier to debug if have a small example
model that reliably demonstrates the problem. At the moment, the single
traceback is not really enough information to go on.

Regards,
Malcolm



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: MultipleObjectsReturned with get() on 1.0-beta1 admin UI

2008-08-25 Thread dchandek

To make this even stranger, the problem only occurs when the pk of the
selected (self-)related object is 1. There's something deep going on
in Django that I can't trace ...

--David

On Aug 25, 4:20 pm, dchandek <[EMAIL PROTECTED]> wrote:
> After upgrading from post-0.96 development version to 1.0-beta1, I now
> get a MultipleObjectsReturned when submitting a change via the Admin
> UI to an object, where the model has a many-to-one relationship with
> itself. From the Python interactive prompt I am not able to reproduce
> the error.
>
> Traceback athttp://dpaste.com/73791/
>
> Perplexed,
> David
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---