-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 12/03/2011 02:13 AM, Anssi Kääriäinen wrote:
> Admin should be fixed [#2259]. Making PK fields non-editable in
> ModelForms would be good, too. Is it OK to consider the current
> ModelForm behavior a bug, or will it need a deprecation cycle?

I think it would need a deprecation cycle. People certainly could be
making use of the current behavior (and there would need to be a way to
get the PK field back into the form, e.g. by explicitly listing it in
"fields"). Excluding PK from ModelForm by default isn't clearly fixing a
bug, it's more protecting people from unintuitive behavior.

(Note that in admin we have the option to display it read-only by
default; ModelForm has no such feature, we'd have to exclude it entirely
by default).

> In my opinion admin getting this wrong is a strong indication about
> how non-intuitive the API is.

That's a fair point.

> It is OK that Django doesn't support primary key updates. But if it
> doesn't support update of PK, then lets error out on primary key
> change. Current behavior of .save() is actually: "save the object to
> DB, except when PK has changed, then do a clone". That is a bad API
> for natural primary keys.
> 
> About breaking current code: my intention is to have a flag to .save()
> which would allow current code to work. .save(clone=True) would get
> current behavior back. Setting the PK to None and doing a save will
> work for AutoField PKs.

So what about admin users who are currently relying on this behavior as
a way to clone objects with natural PKs (given that the
save-and-add-another button is useless with natural PKs unless you can
explicitly give the value for the new row)?

Carl
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk7aWf0ACgkQ8W4rlRKtE2dOowCfRvvpxE3dCAou2Ag/NGzl1t94
8PQAn33d9xdfpEQfcORUAkMER+PEvh1B
=Rhc7
-----END PGP SIGNATURE-----

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to