I have a function in an app called email which I want to profile. When I try to do something like this, it blows up
from django.core.management import BaseCommand
import cProfile
class Command(BaseCommand):
def handle(self, *args, **options):
from email.modname import send_email
cProfile.run('send_email(user_id=1, city_id=4)')
When I run this management command, it throws the following error:
exec cmd in globals, locals
File "<string>", line 1, in <module>
NameError: name 'send_email' is not defined
What am I missing here? How does cProfile evaluate the string (look up func names in the global/local namespace)?