Add a required inline on django admin
|Reported by:||zodman||Owned by:||nobody|
|Severity:||Keywords:||inlines, formset, admin|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Description (last modified by russellm)
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 Changed 5 years ago by russellm
- Description modified (diff)
- milestone 2.0 deleted
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset