I can't find how to debug custom management commands.
When errors happen, they just say something like :
IndexError: list index out of range
How to get more debugging info ?
Like the number of the line where it crashes for instance, that would be helpful.
There is a traceback option that does the trick :
python manage.py command_name --traceback
The command then outputs usual python errors
use -i
option and pdb:
python -i manage.py command_name
failed or not , you will have a python repl, so you can use pdb
to jump into the stacks raising exception:
return executor(sql, params, many, context)
File "/home/gary/PycharmProjects/borges-env/lib/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "/home/gary/PycharmProjects/borges-env/lib/python3.6/site-packages/django/db/utils.py", line 89, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/gary/PycharmProjects/borges-env/lib/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
django.db.utils.DataError: value too long for type character varying(10)
>>> import pdb
>>> pdb.pm()
> /home/gary/PycharmProjects/borges-env/lib/python3.6/site-packages/django/db/backends/utils.py(84)_execute()
-> return self.cursor.execute(sql, params)
(Pdb) param
blablabalablabalablbalbalabla
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With