[Django] #28205: ModelAdmin.prepopulated_fields. Auto generating does not work while editing object

9 views
Skip to first unread message

Django

unread,
May 14, 2017, 3:46:31 AM5/14/17
to django-...@googlegroups.com
#28205: ModelAdmin.prepopulated_fields. Auto generating does not work while editing
object
-------------------------------------+-------------------------------------
Reporter: Ju | Owner: nobody
Type: Bug | Status: new
Component: | Version: 1.11
contrib.admin |
Severity: Normal | Keywords: prepopulated_fields
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
ModelAdmin.prepopulated_fields auto generating works only while creating
new records but not while editing them.

{{{

from django.db import models

class Item(models.Model):
title = models.CharField(max_length=200, blank=False)
slug = models.SlugField(max_length=200)

}}}

{{{

from django.contrib import admin
from .models import Item

class ItemAdmin(admin.ModelAdmin):

prepopulated_fields = {"slug": ("title",)}

admin.site.register(Item, ItemAdmin)
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28205>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 14, 2017, 3:19:49 PM5/14/17
to django-...@googlegroups.com
#28205: Document that ModelAdmin.prepopulated_fields only works on empty forms
--------------------------------------+------------------------------------
Reporter: Ju | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 1.11
Severity: Normal | Resolution:
Keywords: prepopulated_fields | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Tim Graham):

* type: Bug => Cleanup/optimization
* component: contrib.admin => Documentation
* stage: Unreviewed => Accepted


Comment:

That's expected behavior -- `prepopulated_fields` only works on empty
forms. I think the idea is that slugs for existing objects shouldn't
change since that could cause a URL to change. This could be documented.

--
Ticket URL: <https://code.djangoproject.com/ticket/28205#comment:1>

Django

unread,
May 19, 2017, 7:05:01 AM5/19/17
to django-...@googlegroups.com
#28205: Document that ModelAdmin.prepopulated_fields only works on empty forms
-------------------------------------+-------------------------------------
Reporter: Ju | Owner: James
Type: | Seden Smith
Cleanup/optimization | Status: assigned

Component: Documentation | Version: 1.11
Severity: Normal | Resolution:
Keywords: prepopulated_fields | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by James Seden Smith):

* status: new => assigned
* owner: nobody => James Seden Smith


--
Ticket URL: <https://code.djangoproject.com/ticket/28205#comment:2>

Django

unread,
Oct 26, 2017, 12:53:18 PM10/26/17
to django-...@googlegroups.com
#28205: Document that ModelAdmin.prepopulated_fields only works on empty forms
-------------------------------------+-------------------------------------
Reporter: Ju | Owner: Botond
Type: | Béres

Cleanup/optimization | Status: assigned
Component: Documentation | Version: 1.11
Severity: Normal | Resolution:
Keywords: prepopulated_fields | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Botond Béres):

* owner: James Seden Smith => Botond Béres


--
Ticket URL: <https://code.djangoproject.com/ticket/28205#comment:3>

Django

unread,
Oct 26, 2017, 1:21:10 PM10/26/17
to django-...@googlegroups.com
#28205: Document that ModelAdmin.prepopulated_fields only works on empty forms
-------------------------------------+-------------------------------------
Reporter: Ju | Owner: Botond
Type: | Béres
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 1.11
Severity: Normal | Resolution:
Keywords: prepopulated_fields | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Botond Béres):

* has_patch: 0 => 1


Comment:

Opened a [https://github.com/django/django/pull/9290 small PR] which adds
in the `prepopulated_fields` docs that it only works on empty forms.

--
Ticket URL: <https://code.djangoproject.com/ticket/28205#comment:4>

Django

unread,
Oct 28, 2017, 1:28:57 PM10/28/17
to django-...@googlegroups.com
#28205: Document that ModelAdmin.prepopulated_fields only works on empty forms
-------------------------------------+-------------------------------------
Reporter: Ju | Owner: Botond
Type: | Béres
Cleanup/optimization | Status: closed
Component: Documentation | Version: 1.11
Severity: Normal | Resolution: fixed

Keywords: prepopulated_fields | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"56b364bacca0d6a6cd8fbcd93aeb49f3ad46e58c" 56b364ba]:
{{{
#!CommitTicketReference repository=""
revision="56b364bacca0d6a6cd8fbcd93aeb49f3ad46e58c"
Fixed #28205 -- Doc'd that ModelAdmin.prepopulated_fields only works on
add forms.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28205#comment:5>

Django

unread,
Oct 28, 2017, 1:29:05 PM10/28/17
to django-...@googlegroups.com
#28205: Document that ModelAdmin.prepopulated_fields only works on empty forms
-------------------------------------+-------------------------------------
Reporter: Ju | Owner: Botond
Type: | Béres
Cleanup/optimization | Status: closed
Component: Documentation | Version: 1.11
Severity: Normal | Resolution: fixed
Keywords: prepopulated_fields | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"5630f4e6acba6359d7d182de034a6af563025df9" 5630f4e6]:
{{{
#!CommitTicketReference repository=""
revision="5630f4e6acba6359d7d182de034a6af563025df9"
[2.0.x] Fixed #28205 -- Doc'd that ModelAdmin.prepopulated_fields only
works on add forms.

Backport of 56b364bacca0d6a6cd8fbcd93aeb49f3ad46e58c from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28205#comment:6>

Django

unread,
Nov 28, 2018, 3:13:08 PM11/28/18
to django-...@googlegroups.com
#28205: Document that ModelAdmin.prepopulated_fields only works on empty forms
-------------------------------------+-------------------------------------
Reporter: Ju | Owner: Botond
Type: | Béres
Cleanup/optimization | Status: closed
Component: Documentation | Version: 1.11
Severity: Normal | Resolution: fixed
Keywords: prepopulated_fields | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"682cdf6cab8cb76ef1808df45631c39748052e13" 682cdf6c]:
{{{
#!CommitTicketReference repository=""
revision="682cdf6cab8cb76ef1808df45631c39748052e13"
Refs #28205 -- Corrected ModelAdmin.prepopulated_fields docs regarding
when they're populated.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28205#comment:7>

Django

unread,
Nov 28, 2018, 3:13:10 PM11/28/18
to django-...@googlegroups.com
#28205: Document that ModelAdmin.prepopulated_fields only works on empty forms
-------------------------------------+-------------------------------------
Reporter: Ju | Owner: Botond
Type: | Béres
Cleanup/optimization | Status: closed
Component: Documentation | Version: 1.11
Severity: Normal | Resolution: fixed
Keywords: prepopulated_fields | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"a9d9680ea344a243f6e3ed7d0ad8031172458b9a" a9d9680e]:
{{{
#!CommitTicketReference repository=""
revision="a9d9680ea344a243f6e3ed7d0ad8031172458b9a"
[2.1.x] Refs #28205 -- Corrected ModelAdmin.prepopulated_fields docs


regarding when they're populated.

Backport of 682cdf6cab8cb76ef1808df45631c39748052e13 from master.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28205#comment:8>

Reply all
Reply to author
Forward
0 new messages