You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
python -m django shell -c
command crashes when passing Python code with functions, while thepython -c
command works fine.exec
in thehandle
method of thedjango.core.management.commands.shell.Command
class.django
module is not defined in the context of theexec
call, causing aNameError
.exec
, instead of relying on the default global context.The text was updated successfully, but these errors were encountered: