mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-01 04:10:06 -05:00
fixed serializer for food
This commit is contained in:
@@ -338,7 +338,7 @@ class FoodSerializer(UniqueFieldsMixin, WritableNestedModelSerializer):
|
||||
def create(self, validated_data):
|
||||
validated_data['name'] = validated_data['name'].strip()
|
||||
validated_data['space'] = self.context['request'].space
|
||||
supermarket = validated_data.pop('supermarket_category')
|
||||
supermarket = validated_data.pop('supermarket_category', None)
|
||||
obj, created = Food.objects.get_or_create(**validated_data)
|
||||
if supermarket:
|
||||
obj.supermarket_category, created = SupermarketCategory.objects.get_or_create(name=supermarket['name'], space=self.context['request'].space)
|
||||
|
||||
@@ -277,14 +277,14 @@ else:
|
||||
# }
|
||||
|
||||
# SQLite testing DB
|
||||
# DATABASES = {
|
||||
# 'default': {
|
||||
# 'ENGINE': 'django.db.backends.sqlite3',
|
||||
# 'OPTIONS': ast.literal_eval(os.getenv('DB_OPTIONS')) if os.getenv('DB_OPTIONS') else {},
|
||||
# 'NAME': 'db.sqlite3',
|
||||
# 'CONN_MAX_AGE': 600,
|
||||
# }
|
||||
# }
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'OPTIONS': ast.literal_eval(os.getenv('DB_OPTIONS')) if os.getenv('DB_OPTIONS') else {},
|
||||
'NAME': 'db.sqlite3',
|
||||
'CONN_MAX_AGE': 600,
|
||||
}
|
||||
}
|
||||
|
||||
CACHES = {
|
||||
'default': {
|
||||
|
||||
Reference in New Issue
Block a user