#29929: ModelAdmin.prepopulated_fields crashing admin when showing read-only
view
-----------------------------------------+------------------------
Reporter: Sébastiaan | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 2.1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
The values of the `ModelAdmin.prepopulated_fields` field will be used when
showing a read-only view in the admin. This results in a `KeyError`: `"Key
'to_be_prepopulated' not found in 'SampleModelForm'. Choices are: ."`.
{{{
#!python
class SampleModel(models.Model):
input_value = models.TextField()
to_be_prepopulated = models.TextField()
}}}
{{{
#!python
@admin.register(SampleModel)
class SampleModelAdmin(admin.ModelAdmin):
prepopulated_fields = {'to_be_prepopulated': ('input_value',)}
def has_change_permission(self, request, obj=None):
return False
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/29929>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/054.72bd1a930450d49a5081c4152f3f5d1b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.