diff --git a/ereuse_devicehub/inventory/forms.py b/ereuse_devicehub/inventory/forms.py index 62f295d0..da035520 100644 --- a/ereuse_devicehub/inventory/forms.py +++ b/ereuse_devicehub/inventory/forms.py @@ -464,9 +464,9 @@ class TagDeviceForm(FlaskForm): if self.delete: tags = Tag.query.filter(Tag.owner_id == g.user.id).filter_by( device_id=self.device_id - ) + ).order_by(Tag.id) else: - tags = Tag.query.filter(Tag.owner_id == g.user.id).filter_by(device_id=None) + tags = Tag.query.filter(Tag.owner_id == g.user.id).filter_by(device_id=None).order_by(Tag.id) self.tag.choices = [(tag.id, tag.id) for tag in tags] diff --git a/ereuse_devicehub/inventory/views.py b/ereuse_devicehub/inventory/views.py index 5df42ac3..8bb9633b 100644 --- a/ereuse_devicehub/inventory/views.py +++ b/ereuse_devicehub/inventory/views.py @@ -47,7 +47,7 @@ class DeviceListMix(View): tags = ( Tag.query.filter(Tag.owner_id == current_user.id) .filter(Tag.device_id.is_(None)) - .order_by(Tag.created.desc()) + .order_by(Tag.id.asc()) ) if lot_id: @@ -236,7 +236,7 @@ class TagListView(View): def dispatch_request(self): lots = Lot.query.filter(Lot.owner_id == current_user.id) - tags = Tag.query.filter(Tag.owner_id == current_user.id) + tags = Tag.query.filter(Tag.owner_id == current_user.id).order_by(Tag.id) context = { 'lots': lots, 'tags': tags,