prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  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!
  
  
  </issue>
  <code>
  [start of saleor/product/models/utils.py]
  1 from django.utils.encoding import smart_text
  2 
  3 
  4 def get_attributes_display_map(obj, attributes):
  5     display_map = {}
  6     for attribute in attributes:
  7         value = obj.attributes.get(smart_text(attribute.pk))
  8         if value:
  9             choices = {smart_text(a.pk): a for a in attribute.values.all()}
  10             choice_obj = choices.get(value)
  11             if choice_obj:
  12                 display_map[attribute.pk] = choice_obj
  13             else:
  14                 display_map[attribute.pk] = value_pk
  15     return display_map
  16
  [end of saleor/product/models/utils.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/saleor/product/models/utils.py b/saleor/product/models/utils.py
  --- a/saleor/product/models/utils.py
  +++ b/saleor/product/models/utils.py
  @@ -11,5 +11,5 @@
               if choice_obj:
                   display_map[attribute.pk] = choice_obj
               else:
  -                display_map[attribute.pk] = value_pk
  +                display_map[attribute.pk] = value
       return display_map
  
verification_info: {"golden_diff": "diff --git a/saleor/product/models/utils.py b/saleor/product/models/utils.py\n--- a/saleor/product/models/utils.py\n+++ b/saleor/product/models/utils.py\n@@ -11,5 +11,5 @@\n             if choice_obj:\n                 display_map[attribute.pk] = choice_obj\n             else:\n-                display_map[attribute.pk] = value_pk\n+                display_map[attribute.pk] = value\n     return display_map\n", "issue": "Server Error (500) when adding attribute\nHi,\r\n\r\nFirst of all thanks for this excellent software, makes my life easier.\r\n\r\nI deployed it on heroku using the heroku elements (https://elements.heroku.com/buttons/mirumee/saleor).\r\n\r\nThen 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?\r\n\r\nThanks!\r\n\n", "before_files": [{"content": "from django.utils.encoding import smart_text\n\n\ndef get_attributes_display_map(obj, attributes):\n    display_map = {}\n    for attribute in attributes:\n        value = obj.attributes.get(smart_text(attribute.pk))\n        if value:\n            choices = {smart_text(a.pk): a for a in attribute.values.all()}\n            choice_obj = choices.get(value)\n            if choice_obj:\n                display_map[attribute.pk] = choice_obj\n            else:\n                display_map[attribute.pk] = value_pk\n    return display_map\n", "path": "saleor/product/models/utils.py"}]}