create(self, **data) - mansukim1125/JudgeInterface GitHub Wiki
Prototype
create(self, **data: Dict) -> None
์ค๋ช
data
๋ฅผ self.table_name ํ
์ด๋ธ์ ์ถ๊ฐํฉ๋๋ค. perform_create(self, **data)
์ ๋ค๋ฅธ ์ ์ด๋ผ๋ฉด ์ค๋ฒ๋ผ์ด๋ํ์ฌ data
์ ํน์ field์ ๊ฐ์ ๊ฐ๊ณตํ ์ ์์ต๋๋ค.
์ฌ์ฉ ์
๋ค์์ Users์ ์ค๋ฒ๋ผ์ด๋๋ create์ ๋๋ค.
def create(self, **data: Dict):
if 'password' in data:
password = data.get('password')
hashed_password = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt())
data['password'] = hashed_password.decode()
return super().create(**data)
์ ์์๋ฅผ ๋ณด๋ฉด ์
๋ ฅ๋ password
๋ฅผ bcrypt
๋ฅผ ํตํด ์ํธํํ ๊ฐ์ผ๋ก ๋ฎ์ด์์ ์ ์ ์์ต๋๋ค.