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

Fix Django shell command crash with functions #123

Open
archie-ai-code-explain-pr-review bot opened this issue Jul 13, 2024 · 0 comments
Open

Fix Django shell command crash with functions #123

archie-ai-code-explain-pr-review bot opened this issue Jul 13, 2024 · 0 comments

Comments

@archie-ai-code-explain-pr-review
  • The python -m django shell -c command crashes when passing Python code with functions, while the python -c command works fine.
  • The issue is in the usage of exec in the handle method of the django.core.management.commands.shell.Command class.
  • The error message shows that the django module is not defined in the context of the exec call, causing a NameError.
  • The solution is to pass a dictionary containing a minimal set of globals as the second argument to exec, instead of relying on the default global context.
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

0 participants