In settings.py:

`# Try to determine if the django server is running
try:
	from commands import getoutput
	DJANGO_SERVER = getoutput('ps ax').find('manage.py runserver ') > 0
except ImportError:
	DJANGO_SERVER = False
`

In a file which you import:

`from django.conf import settings

if settings.DJANGO_SERVER:
	try:
		import ipdb as pdb
	except ImportError:
		import pdb
		
	def trace():
		pdb.set_trace()
else:
	def trace():
		pass
`

In the file in which you want to insert a trace:

from vs.utils import trace  # vs.utils is where you defined the method above

# some code
trace()
