Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Update all remote IDs at once

Roland Geider6381dbbb3d69
diff --git a/wger/nutrition/migrations/0022_add_remote_id_increase_author_field_length.py b/wger/nutrition/migrations/0022_add_remote_id_increase_author_field_length.py
index 85b98cf5d..4d48aeca3 100644
--- a/wger/nutrition/migrations/0022_add_remote_id_increase_author_field_length.py
+++ b/wger/nutrition/migrations/0022_add_remote_id_increase_author_field_length.py
@@ -9,9 +9,9 @@ def set_external_id(apps, schema_editor):
"""Set remote_id, used by imported ingredients (OFF, etc.)"""
Ingredient = apps.get_model('nutrition', 'Ingredient')
- for ingredient in Ingredient.objects.filter(source_name=Source.OPEN_FOOD_FACTS.value):
- ingredient.remote_id = ingredient.code
- ingredient.save()
+ Ingredient.objects.filter(source_name=Source.OPEN_FOOD_FACTS.value).update(
+ remote_id=models.F('code')
+ )
class Migration(migrations.Migration):
diff --git a/wger/nutrition/off.py b/wger/nutrition/off.py
index fb30a4602..5ca4b85b8 100644
--- a/wger/nutrition/off.py
+++ b/wger/nutrition/off.py
@@ -13,8 +13,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# Standard Library
-
# wger
from wger.nutrition.consts import KJ_PER_KCAL
from wger.nutrition.dataclasses import IngredientData