﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
19082	Improve the prepopulated_fields autocompletion logic	Manuel Saelices	micaelwidell	"I think the logic behind [https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.prepopulated_fields prepopulated fields in admin] sould be improved.

The current condition to decide whether to autocomplete the field is: ''I autocomplete if we are adding the object and it is not already changed by the user''.

The problem I found is the ''we are adding the object'' part of the previous condition. I think is useful not worry about the add/edit context. I prefer the condition ''I autocomplete if the field is not already changed by the user and '''it is empty when the page is loaded'''''

I suppose the current logic is valid because most times the prepopulated fields are {{{SlugField}}} instances, which are usually required. This implies they cannot be empty when we are editing the object (because it was already added with a non empty value). But this is not a required precondition, because you can use the following model and model admin:
{{{
#!python

# models.py
class Person(models.Model):
   name = models.CharField(max_length=200, null=True, blank=True)
   surname = models.CharField(...)
   nickname = models.SlugField(null=True, blank=True)

# admin.py
class PersonAdmin(admin.ModelAdmin):
   prepopulated_fields = {""nickname"": (""name"",)}
}}}
"	Cleanup/optimization	closed	contrib.admin	1.4	Normal	fixed		d1fffuz0r@…	Accepted	1	0	0	0	1	0
