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

When creating creatures, fields could be none #90

Open
tai271828 opened this issue Jan 11, 2023 · 0 comments
Open

When creating creatures, fields could be none #90

tai271828 opened this issue Jan 11, 2023 · 0 comments

Comments

@tai271828
Copy link

Or we will get:

web_1     |   File "/usr/local/lib/python3.7/site-packages/rest_framework/views.py", line 492, in dispatch
web_1     |     response = handler(request, *args, **kwargs)
web_1     |   File "/usr/local/lib/python3.7/site-packages/rest_framework/decorators.py", line 55, in handler
web_1     |     return func(*args, **kwargs)
web_1     |   File "/Disfactory/api/views/factories_cr.py", line 239, in get_nearby_or_create_ohshown_events
web_1     |     return _handle_create_ohshown_events(request)
web_1     |   File "/Disfactory/api/views/factories_cr.py", line 126, in _handle_create_ohshown_events
web_1     |     "maturity": creature["bearType"],
web_1     | KeyError: 'bearType'
web_1     | "POST /api/ohshown-events HTTP/1.1" 500 16854

Solution: change this part in factories_cr.py:

        for creature in post_body["bears"]:
            new_creature_field = {
                "maturity": creature["bearType"],
                "size": creature["bearSize"],
                "gender": creature["bearSex"],
                "display_number": num_creature_max + cnt,
            }
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

No branches or pull requests

1 participant