Opened 7 years ago
Closed 3 years ago
#28357 closed Bug (fixed)
Prepopulated_fields doesn't work for admin.StackedInline.
Reported by: | ChristosKon | Owned by: | Shubh Parmar |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | Normal | Keywords: | admin, stackedinline, prepopulated_fields |
Cc: | Ryan Siemens, Zoltán Szatmáry, Shubh Parmar | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | yes |
Description
I think that I found a bug (new to Django)
Prepopulated_fields doesn't work for StackedInline class while it works fine for TabularInline class.
Please let me know if you need any more information.
Attachments (1)
Change History (21)
comment:1 by , 7 years ago
Resolution: | → worksforme |
---|---|
Status: | new → closed |
comment:2 by , 6 years ago
Cc: | added |
---|---|
Resolution: | worksforme |
Status: | closed → new |
Version: | 1.11 → 2.1 |
Reopening as I ran into this issue (at least similar) today. Some additional info:
The prepopulated_fields
will work for the extra
forms specified, in the inline, but any additional forms added via "Add another <Model>" will not run the js that pre populates the field.
class ArticleInline(admin.StackedInline): model = Article extra = 2 # will only prepopulate the ``slug`` field for the 2 ``extra`` forms # in the formset prepopulated_fields = {"slug": ("title",)}
Verified this issue is happening in 2.1 and 1.11 and attached a minimal project that reproduces the issue.
To reproduce:
- extract the attached project
- run the migrations
- create a superuser
- navigate to
admin/myapp/blog/add/
- adding a title to extra forms in the the stacked inline articles prepopulates the slug field
- click "Add another Article"
- ASSERT adding a title the newly added stacked inline article form does not prepopulate the slug field
Here is a screen grab showing the results of steps 5-7 https://zappy.zapier.com/22F716E5-1D64-4763-B731-DE62D24F8FC0.mp4
comment:3 by , 6 years ago
UI/UX: | set |
---|
comment:4 by , 6 years ago
Triage Stage: | Unreviewed → Accepted |
---|
Thanks for the very detailed reproduction case Ryan.
comment:5 by , 6 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:6 by , 5 years ago
Has patch: | set |
---|---|
Summary: | Prepopulated_fields doesn't work for admin.StackedInline → Prepopulated_fields doesn't work for admin.StackedInline. |
Version: | 2.1 → master |
comment:7 by , 5 years ago
Needs tests: | set |
---|
comment:9 by , 5 years ago
Patch needs improvement: | set |
---|
comment:10 by , 4 years ago
Easy pickings: | set |
---|
comment:11 by , 3 years ago
Owner: | removed |
---|---|
Status: | assigned → new |
comment:15 by , 3 years ago
Cc: | added |
---|---|
Owner: | set to |
Yesterday I made a PR for this one. https://github.com/django/django/pull/14967
It only required changes in the inlines.js file.
comment:16 by , 3 years ago
Needs tests: | set |
---|
comment:17 by , 3 years ago
Owner: | changed from | to
---|
Since there is no updates regarding this ticket for weeks, I want to work on it.
comment:18 by , 3 years ago
Cc: | added |
---|
comment:20 by , 3 years ago
Easy pickings: | unset |
---|---|
Needs tests: | unset |
Patch needs improvement: | unset |
Status: | new → assigned |
comment:21 by , 3 years ago
Patch needs improvement: | set |
---|
comment:22 by , 3 years ago
Patch needs improvement: | unset |
---|---|
Triage Stage: | Accepted → Ready for checkin |
I tested with a a simple project and couldn't reproduce a problem. Please provide more details.