from django.utils.encoding import smart_text


def get_attributes_display_map(obj, attributes):
    display_map = {}
    for attribute in attributes:
        value = obj.attributes.get(smart_text(attribute.pk))
        if value:
            choices = {smart_text(a.pk): a for a in attribute.values.all()}
            choice_obj = choices.get(value)
            if choice_obj:
                display_map[attribute.pk] = choice_obj
            else:
                display_map[attribute.pk] = value_pk
    return display_map

saleor/product/models/utils.py
from django.utils.encoding import smart_text


def get_attributes_display_map(obj, attributes):
    display_map = {}
    for attribute in attributes:
        value = obj.attributes.get(smart_text(attribute.pk))
        if value:
            choices = {smart_text(a.pk): a for a in attribute.values.all()}
            choice_obj = choices.get(value)
            if choice_obj:
                display_map[attribute.pk] = choice_obj
            else:
                display_map[attribute.pk] = value
    return display_map

saleor/product/models/utils.py
diff --git a/saleor/product/models/utils.py b/saleor/product/models/utils.py
index 009950b84df..624a71b8012 100644
--- a/saleor/product/models/utils.py
+++ b/saleor/product/models/utils.py
@@ -11,5 +11,5 @@ def get_attributes_display_map(obj, attributes):
             if choice_obj:
                 display_map[attribute.pk] = choice_obj
             else:
-                display_map[attribute.pk] = value_pk
+                display_map[attribute.pk] = value
     return display_map

Server Error (500) when adding attribute
Hi,

First of all thanks for this excellent software, makes my life easier.

I deployed it on heroku using the heroku elements (https://elements.heroku.com/buttons/mirumee/saleor).

Then I tried to add an attribute but that resulted in Server Error (500) page. Is this expected behavior? Any settings that have to be changed? If yes then any way to do that on heroku?

Thanks!

