Skip to content

Commit

Permalink
Правки после ревью v3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Lozhkin-pa authored and Lozhkin-pa committed Oct 4, 2023
1 parent df3fb70 commit db7baac
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion backend/foodgram/foodgram/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
BASE_DIR = Path(__file__).resolve().parent.parent


DEBUG = False
DEBUG = True

ALLOWED_HOSTS = ['127.0.0.1', 'localhost', '51.250.106.248', 'myfoodgramproject.sytes.net']

Expand Down
15 changes: 13 additions & 2 deletions backend/foodgram/recipes/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,20 @@ class RecipeCreateUpdateSerializer(serializers.ModelSerializer):

def validate(self, data):
if 'recipe_ingredients' not in data:
raise serializers.ValidationError('Отсутствуют ингредиенты!')
raise serializers.ValidationError(
{'errors': 'Отсутствуют ингредиенты!'}
)
if 'tags' not in data:
raise serializers.ValidationError('Отсутствуют теги!')
raise serializers.ValidationError(
{'errors': 'Отсутствуют теги!'}
)
if Recipe.objects.filter(
name=data.get('name'),
text=data.get('text')
).exists():
raise serializers.ValidationError(
{'errors': 'Такой рецепт уже существует!'}
)
return data

def __add_ingredients(self, recipe, ingredients_data):
Expand Down

0 comments on commit db7baac

Please sign in to comment.