Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix model serialization
Patryk Zawadzki7537cfbc80dc
diff --git a/saleor/userprofile/models.py b/saleor/userprofile/models.pyindex d6a01baa81..738d92a882 100644--- a/saleor/userprofile/models.py+++ b/saleor/userprofile/models.py@@ -8,13 +8,16 @@ from django.forms.models import model_to_dictfrom django.utils import timezonefrom django.utils.encoding import python_2_unicode_compatiblefrom django.utils.translation import pgettext_lazy-from django_countries.fields import CountryField+from django_countries.fields import Country, CountryFieldclass AddressManager(models.Manager):def as_data(self, address):- return model_to_dict(address, exclude=['id', 'user'])+ data = model_to_dict(address, exclude=['id', 'user'])+ if isinstance(data['country'], Country):+ data['country'] = data['country'].code+ return datadef are_identical(self, addr1, addr2):data1 = self.as_data(addr1)