I have some code that doesn't do what I would expect even after thorough debugging.
I have
class AgregatororderAdmin(admin.ModelAdmin):
...
on which I call
def change_view(self, request, object_id, form_url='', extra_context = None):
if self.form.base_fields["ProcessingPersonAdminId"].initial == None:
self.form.base_fields["ProcessingPersonAdminId"].initial = request.user.id
self.form.base_fields["ProcessingPersonName"].initial = request.user.username
...
return super().change_view(request, object_id, form_url, extra_context=extra_context, )
when I check, the initial values, it is set correctly. But in the admin change view it does not display.
I would appreciate any hint on why the changes are not applied.
question from:
https://stackoverflow.com/questions/65882225/why-is-setting-initial-field-values-not-working-in-django-admin 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…