Opened 16 years ago
Closed 4 years ago
#11803 closed Bug (fixed)
Admin does not update every ForeignKey select of the same model
| Reported by: | Owned by: | Marcelo Galigniana | |
|---|---|---|---|
| Component: | contrib.admin | Version: | dev |
| Severity: | Normal | Keywords: | admin select foreignkey |
| Cc: | aaboffill@… | Triage Stage: | Ready for checkin |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Consider I have the following models:
class City(models.Model): name = models.CharField(80) state = models.CharField(2) class Person(models.Model): living_city = models.ForeignKey(City) born_city = models.ForeignKey(City, related_name='born_city_set')
When I go to admin to add a new Person, I have the option to add a city at living_city select and born_city select, if I add a city at living_city select, for example, the born_city select does not update automatically, it remains empty or without the new option.
Change History (13)
comment:1 by , 16 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:2 by , 14 years ago
| Severity: | → Normal |
|---|---|
| Type: | → Bug |
comment:3 by , 14 years ago
| UI/UX: | unset |
|---|
comment:5 by , 14 years ago
I'd like to vote for this feature as it is crucial for our projects. Without it customers have to edit the entities first (City) they will refer to in other models (Person) which is very bad from a usability point of view!
comment:7 by , 9 years ago
| Cc: | added |
|---|
I think that is a little difficult to find a simple and elegant way to fix this ticket.
The Select fields are updated in RelatedObjectLookups.js when the popup is closed after to add the new record. In order to update all fields related with the same model, is necessary to have at least something to identify all HTML elements with the same model, something like data-model-ref="". Now this is a little more easy with the new template-based widget rendering, because is easy to add the attribute to the template.
But to make this simple change in the template, is necessary to update all tests related with the html content of widgets. And I don't know if to add a new attribute to the field widget template it's finally convenient or worthwhile.
If finally to add something like data-model-ref="" in the field widget template is not a bad idea, I can work on a solution.
comment:8 by , 4 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
comment:10 by , 4 years ago
| Version: | 1.1 → dev |
|---|
comment:11 by , 4 years ago
| Patch needs improvement: | set |
|---|
The suggest patch looks kind of neat, so 👍
I think limit_choices_to (and maybe other wiggles) need consideration for it to be 100%
comment:12 by , 4 years ago
| Patch needs improvement: | unset |
|---|---|
| Triage Stage: | Accepted → Ready for checkin |
Change UI/UX from NULL to False.