Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions db/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Generated by Django 6.0.4 on 2026-05-04 00:26

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This violates checklist item #3: Missing related_name='skills' on the ForeignKey. Add related_name='skills' to enable access to related models from the Race side.


operations = [
migrations.CreateModel(
name='Guild',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=255, unique=True)),
('description', models.TextField(null=True)),
],
),
migrations.CreateModel(
name='Race',
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This violates checklist item #3: Missing related_name on the ForeignKey. Add related_name='players' to enable access to related models from the Race side.

fields=[
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This violates checklist item #3: Missing related_name on the ForeignKey. Add related_name='players' to enable access to related models from the Guild side.

('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=255, unique=True)),
('description', models.TextField(blank=True)),
],
),
migrations.CreateModel(
name='Player',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('nickname', models.CharField(max_length=255, unique=True)),
('email', models.EmailField(max_length=255)),
('bio', models.CharField(max_length=255)),
('created_at', models.DateTimeField(auto_now_add=True)),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CHECKLIST ITEM #3 violation: The migration is missing related_name='players' on the Player.guild ForeignKey. Regenerate migrations to match the current models.

('guild', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='db.guild')),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CHECKLIST ITEM #3 violation: The migration is missing related_name='players' on the Player.race ForeignKey. The migration must be regenerated to include this attribute.

('race', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='db.race')),
],
),
migrations.CreateModel(
name='Skill',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=255, unique=True)),
('bonus', models.CharField(max_length=255)),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CHECKLIST ITEM #3 violation: The migration is missing related_name='skills' on the Skill.race ForeignKey. Run makemigrations to regenerate this migration to match the current model definitions.

('race', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='db.race')),
],
),
]
37 changes: 37 additions & 0 deletions db/models.py
Original file line number Diff line number Diff line change
@@ -1 +1,38 @@
from django.db import models


class Race(models.Model):
name = models.CharField(max_length=255, unique=True)
description = models.TextField(blank=True)


class Skill(models.Model):
name = models.CharField(max_length=255, unique=True)
bonus = models.CharField(max_length=255)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing related_name='skills' - This violates checklist item #3 which requires adding related_name to all ForeignKey fields

race = models.ForeignKey(
Race,
on_delete=models.CASCADE,
related_name="skills"
)


class Guild(models.Model):
name = models.CharField(max_length=255, unique=True)
description = models.TextField(null=True)


class Player(models.Model):
nickname = models.CharField(max_length=255, unique=True)
email = models.EmailField(max_length=255)
bio = models.CharField(max_length=255)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing related_name='players' on this field - This violates checklist item #3 which requires adding related_name to all ForeignKey fields

race = models.ForeignKey(
Race, on_delete=models.CASCADE,
related_name="players"
)
guild = models.ForeignKey(
Guild,
on_delete=models.SET_NULL,
null=True,
related_name="players"
)
created_at = models.DateTimeField(auto_now_add=True)
47 changes: 42 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,48 @@
import init_django_orm # noqa: F401
import json
import os

from db.models import Race, Skill, Player, Guild
import django

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "your_project.settings")
django.setup()

from db.models import Guild, Player, Race, Skill # noqa: E402


def main() -> None:
Comment on lines 11 to 12
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This violates checklist item #3: missing related_name on ForeignKey to Race. Add related_name='skills' to allow access from Race to related skills.

pass
with open("players.json", "r") as f:
players_data = json.load(f)

for nickname, data in players_data.items():
race_data = data["race"]
race, _ = Race.objects.get_or_create(
name=race_data["name"],
defaults={"description": race_data.get("description", "")}
)

for skill_data in race_data.get("skills", []):
Skill.objects.get_or_create(
Comment on lines +23 to +24
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This violates checklist item #3: missing related_name on ForeignKey to Race. Add related_name='players' to allow access from Race to related players.

name=skill_data["name"],
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This violates checklist item #3: missing related_name on ForeignKey to Guild. Add related_name='players' to allow access from Guild to related players.

defaults={
"bonus": skill_data["bonus"],
"race": race,
}
)

guild = None
if data.get("guild"):
guild_data = data["guild"]
guild, _ = Guild.objects.get_or_create(
name=guild_data["name"],
defaults={"description": guild_data.get("description")}
)

Comment on lines +38 to 39
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This violates checklist item #3: missing related_name in migration for Player.guild ForeignKey. Update the migration to include related_name='players'.

if __name__ == "__main__":
main()
Player.objects.get_or_create(
Comment on lines 39 to +40
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This violates checklist item #3: missing related_name in migration for Player.race ForeignKey. Update the migration to include related_name='players'.

nickname=nickname,
defaults={
"email": data["email"],
"bio": data.get("bio", ""),
"race": race,
"guild": guild,
}
)
Loading