[drf | ingredient] Build a Backend REST API - 31

Hyeseong·2021년 3월 8일
0

Add ingredient model🥶

새로운 엔드포인트인 ingredinet를 만들도록 할게요.

test_models🥴

test_models.py 파일의 가장 아래에 아래와 같이 테스트 메소드를 정의 할게요.

def test_ingredient_str(self):
	"""Test the ingredient string representation"""
    ingredient = models.Ingredient.objects.create(
    	user=sample_user(),
        name='Cucumber'
    )
    
    self.assertEqual(str(ingredient), ingredient.name)

models😰

core/models.py

migrations🤯

모델을 생성할게요.

❯ docker-compose run --rm app sh -c "python manage.py makemigrations"
Creating recipe-app-api2_app_run ... done
Migrations for 'core':
  core/migrations/0003_ingredient.py
    - Create model Ingredient

admin🥺

core/admin.py 파일 안 30번째 줄을 통해서 관리자 사이트에 따끈따근하게 만든 모델을 등록하도록 할게요.

test🐹

테스트 코드가 통과되었어요.

profile
어제보다 오늘 그리고 오늘 보다 내일...

0개의 댓글