1차 프로젝트가 시작되었다.
우리팀은 코스메틱 브랜드 Dr.Jart의 커머스 웹사이트를 디저트를 판매하는 커머스 웹사이트 Dr.Tart로 바꿔 클론코딩을 진행하기로 하였다.
백엔드 파트의 첫 미션은 ERD 모델링이었는데, 생각보다 장바구니와 오더의 관계성을 고려하는 것이 쉽지 않았다.
아래는 멘토님 ERD 모델링 리뷰 사항.
ERD 수정 사항 및 공부 해봤으면 하는 사항
from django.db import models
from django.db.models.fields import URLField
from users.models import User
class Menu(models.Model):
name = models.CharField(max_length=20)
class Meta:
db_table='menu'
class Category(models.Model):
name = models.CharField(max_length=50)
menu = models.ForeignKey(Menu, on_delete=models.CASCADE)
class Meta:
db_table='category'
class Product(models.Model):
korean_name = models.CharField(max_length=20)
english_name = models.CharField(max_length=20)
thumbnail_image_url = models.URLField(max_length=200)
price = models.DecimalField(max_digits=10, decimal_places=2)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
vegan_or_not = models.BooleanField(default=False, null=False)
sugar_level = models.IntegerField(default=1)
category = models.ForeignKey(Category, on_delete=models.CASCADE)
description = models.CharField(max_length=1000)
class Meta:
db_table='products'
class Image(models.Model):
url = models.URLField(max_length=300)
product = models.ForeignKey(Product, on_delete=models.CASCADE)
class Meta:
db_table='images'
class Review(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
product = models.ForeignKey(Product, on_delete=models.CASCADE)
content = models.CharField(max_length=200, null=True)
review_image_url = URLField(max_length = 300, null=True)
created_at = models.DateTimeField(auto_now_add=True, null=True)
updated_at = models.DateTimeField(auto_now=True, null=True)
class Meta:
db_table='reviews'
class ReviewComment(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
review = models.ForeignKey(Review, on_delete=models.CASCADE)
content = models.CharField(max_length=100, null=True)
class Meta:
db_table='review_comments'
class Like(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
product = models.ForeignKey(Product, on_delete=models.CASCADE)
class Meta:
db_table='likes'
from django.db import models
class Cart(models.Model):
product = models.ForeignKey('products.Product', on_delete=models.CASCADE)
user = models.ForeignKey('users.User', on_delete=models.CASCADE)
quantity = models.IntegerField(default=0)
class Meta:
db_table = 'carts'
class OrderStatus(models.Model):
status = models.CharField(max_length=20)
class Meta:
db_table = 'order_status'
class Order(models.Model):
user = models.ForeignKey('users.User', on_delete=models.CASCADE)
created_at = models.DateTimeField(auto_now_add=True, null=True)
updated_at = models.DateTimeField(auto_now=True, null=True)
address = models.CharField(max_length=100)
order_status = models.ForeignKey('OrderStatus', on_delete=models.CASCADE)
class Meta:
db_table = 'orders'
class OrderItem(models.Model):
order = models.ForeignKey('Order', on_delete=models.CASCADE)
product = models.ForeignKey('products.Product', on_delete=models.CASCADE)
quantity = models.IntegerField(default=1)
created_at = models.DateTimeField(auto_now_add=True, null=True)
updated_at = models.DateTimeField(auto_now=True, null=True)
class Meta:
db_table = 'order_items'
from django.db import models
class User(models.Model):
name = models.CharField(max_length=100)
email = models.CharField(max_length=250, unique=True)
password = models.CharField(max_length=300)
address = models.CharField(max_length=100)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
vegan_or_not = models.BooleanField(default=False)
class Meta:
db_table = 'users'