Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Solution #1017

wants to merge 3 commits into from

Conversation

Atikiho
Copy link

@Atikiho Atikiho commented Nov 1, 2024

No description provided.

Copy link

@Mxbely Mxbely left a 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

Comment on lines +16 to +22
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)
Copy link

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

Comment on lines +30 to +37
player = Player(
nickname=player_name,
email=player_data["email"],
bio=player_data["bio"],
race=race,
guild=guild,
)
player.save()
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants