Inline model admin does not respect model field default values.
|Reported by:||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Given the abbreviated code below, in the admin view for Project Proposals there will be three (the default value of "extra") new Resubmit Project Proposal Links each with their own unique resubmit_id, and there will be a link to "+ Add another Resubmit Project Proposal Link". This works the first time it's clicked. That is the new (fourth) Resubmit Project Proposal Link will have a unique (distinct from the first three at least) resubmit_id, let's say 1234. But each time the link is clicked afterwards the resubmit_id in the newly created Resubmit Project Proposal Link will always be 1234.
def _default_resubmit_id(): return uuid.uuid4().hex class ResubmitProjectProposalLink(models.Model): resubmit_id = fields.RequiredCharField(default=_default_resubmit_id) projectproposal = fields.RequiredForeignKey('ProjectProposal', related_name='resubmit_projectproposal_links') class ResubmitProjectProposalLinkInline(admin.StackedInline): model = ResubmitProjectProposalLink class ProjectProposalAdmin(admin.ModelAdmin): inlines = [ResubmitProjectProposalLinkInline]