ChooserBlock should use pk instead of id

pull/2130/merge
alexpilot11 2016-01-19 17:38:10 -05:00 zatwierdzone przez Matt Westcott
rodzic 690255c2ee
commit 5270c14444
4 zmienionych plików z 5 dodań i 2 usunięć

Wyświetl plik

@ -10,6 +10,7 @@ Changelog
* Fix: Deleting a page content type now preserves existing pages as basic Page instances, to prevent tree corruption
* Fix: The `Page.path` field is now explicitly given the "C" collation on PostgreSQL to prevent tree ordering issues when using a database created with the Slovak locale
* Fix: Wagtail's compiled static assets are now put into the correct directory on Windows (Aarni Koskela)
* Fix: `ChooserBlock` now correctly handles models with primary keys other than `id` (alexpilot11)
1.3.1 (05.01.2016)
~~~~~~~~~~~~~~~~~~

Wyświetl plik

@ -96,6 +96,7 @@ Contributors
* benjaoming
* Alexander Bogushov
* Aarni Koskela
* alexpilot11
Translators

Wyświetl plik

@ -27,6 +27,7 @@ Bug fixes
* Deleting a page content type now preserves existing pages as basic Page instances, to prevent tree corruption
* The ``Page.path`` field is now explicitly given the "C" collation on PostgreSQL to prevent tree ordering issues when using a database created with the Slovak locale
* Wagtail's compiled static assets are now put into the correct directory on Windows (Aarni Koskela)
* ``ChooserBlock`` now correctly handles models with primary keys other than ``id`` (alexpilot11)
Upgrade considerations

Wyświetl plik

@ -353,11 +353,11 @@ class ChooserBlock(FieldBlock):
return None
def get_prep_value(self, value):
# the native value (a model instance or None) should serialise to an ID or None
# the native value (a model instance or None) should serialise to a PK or None
if value is None:
return None
else:
return value.id
return value.pk
def value_from_form(self, value):
# ModelChoiceField sometimes returns an ID, and sometimes an instance; we want the instance