5👍
To run green unicorn in a reverse proxy configuration (under nginx) in a debugger / debug mode, enter the following settings in PyCharm‘s Run / Django / Edit configurations:
Of course, use whatever port (instead of 7777
) you have configured your nginx to proxy to.
4👍
Ok I’ve recently stumbed upon similar problem. I wasn’t able to apply @dudklein solution (I get I/O Errors while debugger was trying to take input – ipdb, pdb etc.)
I used remote python debbuger – winpdb and it’s embedded debugging.
-
install winpdb in Your virtualenv
pip install winpdb
-
import and run embedded debugger in Your code:
import rpdb2 rpdb2.start_embedded_debugger('pass')
-
run gunicorn with –timeout argument
gunicorn -t 3600 env:application
-
run proper view using browser eg.
http://127.0.0.1:8000/your-view/
-
connect to embedded debugger using winpdb:
winpdb -a /path/to/django/app/views.py
It will prompt You for a password (use one You set in Your code, in my example it is ‘pass’) and run nice GUI with debugger.
-
if You need tutorial for
winpdb
– here You are.
- Model class doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS
- Google App Engine logs a mess of New connection for … and Client closed local connection on
- My Django installs in virtual env are missing admin templates folder
- Nginx location path with proxy_pass
2👍
If you are able to launch gunicorn pointing at an application
instance that is an instance of the DebuggedApplication
class from the werkzeug
library, you will be able to set break points using the werkzeug debugger with import ipdb; ipdb.set_trace()
right in your browser.
import django.core.handlers.wsgi
from werkzeug.debug import DebuggedApplication
application = django.core.handlers.wsgi.WSGIHandler()
application = DebuggedApplication(application, evalex=True)
Make sure you install werkzeug library and ipdb of course. (pip install werkzeug
and pip install ipdb
)
- Django subquery throws "more than one row returned by a subquery used as an expression"
- How do I change the choices in a Django model?
- Pytest and Django settings runtime changes
2👍
I managed now to use gunicron with djnago and ipdb.
run python -m ipdb manage.py run_gunicorn --debug -t 3600
I’m using Django 1.4 and gunicorn 0.16.1. then you can normally use the import ipdb; ipdb.set_trace()
in the code. There is no need for the werkzeug
library.
I’m trying to debug a facebook app, so I can’t use the build in development server, because facebook tries to use SSL and the dev server just can’t respond properly
While I was looking for a solution, I found a post pdb: Using the Python debugger in Django that suggests to run python -m pdb manage.py runserver
all the time. Although this is not necessary with django’s dev server, I decided to give it a try with gunicordn and ipdb and it worked.
- Django: Reading Array of JSON objects from QueryDict
- Modulus/Modulo equivalent operator/function in django templates?
- Django – how can I access the form field from inside a custom widget
0👍
What I finally ended up doing is run python manage.py runserver <your_external_IP>:8000
when I want to use pdb
.
So you need to have 2 different repositories in the same machine, one being LIVE production build (the one running gunicorn
) and the other being the TEST build, the one I need to debug on where I use pdb
. When things seem stable on TEST build I merge the TEST branch
with LIVE branch
. No development or changes happen on LIVE branch
that way I avoid merge conflicts.
Hopefully this helps others who are addicted to pdb
😉
- Recursive crawling with Python and Scrapy
- Query for enum value in GraphQL
- A Simple View to Display/Render a Static image in Django
- Django dependent select
- Pytest and Django settings runtime changes