Opened 15 years ago
Closed 15 years ago
#15174 closed (duplicate)
Add a required inline on django admin
| Reported by: | zodman | Owned by: | nobody |
|---|---|---|---|
| Component: | contrib.admin | Version: | dev |
| Severity: | Keywords: | inlines, formset, admin | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description (last modified by )
For example: If you have a User and UserProfile, you can set up the Admin site to display an inline for the UserProfile.
If the user provides data for the UserProfile, it will be validated and saved.
However, an empty form also passes validation -- there's no easy way to require that the user populate the UserProfile inline.
More details and description on Stack Overflow.
I propouse to use some like this:
class ProfileInline(admin.StackedInline):
"""
Allows profile to be added when creating user
"""
model = Profile
extra = 1
max_num = 1
formset = RequiredInlineFormSet
formset_required = True
Change History (3)
comment:1 by , 15 years ago
| Description: | modified (diff) |
|---|---|
| milestone: | 2.0 |
comment:2 by , 15 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
Broadly, I can accept the use case. However, I'm inclined to say that the solution lies in Formsets, not the admin.
comment:3 by , 15 years ago
| Resolution: | → duplicate |
|---|---|
| Status: | new → closed |
This is essentially a dupe of #14832. That is one tough problem to solve...
In future, please don't use links to external sites like StackOverflow to provide a basic description of the problem you're trying to solve.