diff options
author | Filipp Lepalaan <filipp@mac.com> | 2015-09-10 16:19:54 +0300 |
---|---|---|
committer | Filipp Lepalaan <filipp@mac.com> | 2015-09-10 16:19:54 +0300 |
commit | 5ae2336abc50f6874e5c0df785d3dbe5016d459d (patch) | |
tree | b308194a6a2ed90a8f68cb5a0ba2006fefe706b0 /servo/models | |
parent | 7b6774fba294988693ea227717dc789db898072c (diff) | |
download | Servo-5ae2336abc50f6874e5c0df785d3dbe5016d459d.tar.gz Servo-5ae2336abc50f6874e5c0df785d3dbe5016d459d.tar.bz2 Servo-5ae2336abc50f6874e5c0df785d3dbe5016d459d.zip |
Fix MultipleObjectsReturned exception
We cannot enforce SN uniqueness so let’s just use the first match when
creating order with device SN
Diffstat (limited to 'servo/models')
-rw-r--r-- | servo/models/order.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/servo/models/order.py b/servo/models/order.py index 62333b5..d968068 100644 --- a/servo/models/order.py +++ b/servo/models/order.py @@ -268,9 +268,9 @@ class Order(models.Model): Adds device to order using serial number """ sn = sn.upper() - try: - device = Device.objects.get(sn=sn) - except Device.DoesNotExist: + device = Device.objects.filter(sn=sn).first() + + if device is None: device = Device.from_gsx(sn) device.save() |