-
Notifications
You must be signed in to change notification settings - Fork 917
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Solution #1017
base: master
Are you sure you want to change the base?
Solution #1017
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Separating the logic creation function would be improved readability, and get_or_create can raise exceptions, so would be better use try/except
skills = [] | ||
for skill_data in player_data["race"]["skills"]: | ||
skill, _ = Skill.objects.get_or_create( | ||
name=skill_data["name"], | ||
defaults={"bonus": skill_data["bonus"], "race": race} | ||
) | ||
skills.append(skill) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You do not need save skiils
player = Player( | ||
nickname=player_name, | ||
email=player_data["email"], | ||
bio=player_data["bio"], | ||
race=race, | ||
guild=guild, | ||
) | ||
player.save() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use get_or_create for create player and don't use variables
No description provided.