Opened 17 years ago
Closed 14 years ago
#5497 closed Bug (worksforme)
OneToOneField limit_choices_to filters parent set in admin
Reported by: | Peter Baumgartner | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | Normal | Keywords: | onetoonefield |
Cc: | sgt.hulka@… | Triage Stage: | Accepted |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Setting limit_choices_to on a OneToOneField filters the queryset displayed in admin for the parent field.
Seeing this in current SVN (6304)
Example models:
from django.db import models class Place(models.Model): name = models.CharField(max_length=50) class Admin: pass def __unicode__(self): return u"%s the place" % self.name class Restaurant(models.Model): place = models.OneToOneField(Place, limit_choices_to={'name': 'My Place'}) serves_hot_dogs = models.BooleanField() serves_pizza = models.BooleanField() class Admin: pass def __unicode__(self): return u"%s the restaurant" % self.place.name
Change History (9)
comment:1 by , 17 years ago
comment:2 by , 17 years ago
Cc: | added |
---|
comment:3 by , 17 years ago
I'm a bit confused -- limit_choices_to is supposed to limit the choices... what did you expect to happen?
comment:4 by , 17 years ago
From the example above, I would expect limit_choices_to
to limit the Place
choices in the Restaurant
model.
The unexpected behavior comes when viewing Place
objects in admin. It only displays objects that match the limit_choices_to
that is set in Restaurant
I haven't checked whether this still occurs in trunk.
comment:5 by , 17 years ago
Triage Stage: | Unreviewed → Accepted |
---|
Please do check if this still applies on trunk and close the ticket if it doesn't.
comment:7 by , 17 years ago
Does anyone know if this occurs in newforms-admin, this seems like a problem with the admin filtering, not necessarily the model/queryset.
comment:8 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → Bug |
comment:9 by , 14 years ago
Easy pickings: | unset |
---|---|
Resolution: | → worksforme |
Status: | new → closed |
I tested this against [16164] using the models above in the current admin. The admin list display for Places worked properly for me. I'm closing this as working in newforms-admin.
To further clarify, in the above example, only places with the name 'My Place' will be displayed in admin.