My app is pretty slow even in a dev environment so I would like to figure out what's slowing it down so I can try and fix it.
I know about the debug toolbar and according to what it reports neither the database queries nor the downloaded sources are the issue, so it must be the business logic.
However, I cannot run the PyCharm profiler with the Django server because, well, it's not like running a script.
How may I profile Django with PyCharm?
You should probably set configuration properly.
Then click on Edit Configurations...
The main thing is to set Interpreter (your virtual environment). You don't have to set Custom Run Command if you use python manage.py runserver
Then you can run Django server directly from PyCharm ann Profiler too.
Related
I can't get Python debugger to work on PyCharm 2022.1.2 with Django 4.
When I set the breakpoint inside the view function and then call this view in the browser, nothing happens when started in debug mode...
breakpoint_selected
However breakpoint is hit when I set it for import.
breakpoint_hit
I have 2 configurations, one for Python and one for Django Server, both don't work.
config1
config2
Went through numerous JetBrains tickets with people reporting similar problem but didn't find the solution there. Also tried creating second run configuration, for Python instead Django Server, but this also didn't help.
Solved this by deleting the .idea directory from top-level django project dir. Not sure what were the mechanics behind it, but it worked and now breakpoints work perfectly.
we have a django project on a development server which is running within a virtual environment. I was hoping to be able to use VS Code for development from my local PC, but I am not sure if I am able to or not. It seems like something that would make sense to do!
I think I have managed to set the interpreter as the virtualenv on the server using UNC paths and have activated it, but when I try to run manage.py to create a new app, I get No module named 'django' which perhaps suggested the virtualenv hasn't activate properly?
Is it possible to use VS Code in this way?
thanks,
Phil
You can try extension named "Remote-SSH"
You can edit and debug on a remote machine with VS Code just like you could if the source code was local.
You can alos refer to the document of vscode for more details.
Whenever I run my python django application in Intellij, it shows me a dialog box saying configuration is incorrect and gives me an option to edit or run anyway.
Following is the screenshot of my configuration. Not sure what is it that I am missing.
Update: It does show intermittently in the same configuration dialog box that Django project root is not configured and I am not sure how I can do that. Also, when I run the project anyway, it says,
No manage.py file specified in Settings->Django Support
I am not sure how is the above issue fixable directly but after pressing run on manage.py to create a new configuration and providing it script parameters runserver 127.0.0.1:8000, it worked without errors.
In the above older configuration, Intellij was running a different command
python3.5 /Users/myuser/.virtualenvs/myorg/bin/django-admin.py runserver 8000
I'm developing a Python app for AppEngine using Eclipse / Pydev and need to debug with persistent data stored in the local NDB.
Now, the default path for the NDB on my Linux machine is /tmp and this gets discarded after each reboot. I couldn't find a way to tell Eclipse to use a custom path for the NDB, so I finally resorted to starting the dev_appserver.py via the terminal with:
dev_appserver.py --datastore_path=/home/myfolder/workspace/myapp_datastore app.yaml
Now when I start the debugger I really need persistent data to trace some tricky bugs, but as mentioned, I couldn't find a way to tell eclipse where to store the local NDB so as a consequence I can't use the debugger with persistent data.
Anybody knows a solution?
Tks!
Note: I'm a PyCharm, not an Eclipse user, the answer is based on info I saw.
A Run Configuration window with an Arguments tab allowing you to configure optional arguments for dev_appserver.py is mentioned in the (rather old) Cant Run Google appengine python app on eclipse although launcher works fine, but confirmed in 4.4. Run your application:
You still can use the command line to run your GAE application. But we
are now going to configure Eclipse to allow you to run your
application directly from Eclipse. Right-click on "todo.py", select
Run As ▸ Run Configuration. Under Main Module maintain the path to
dev_appserver.py.
Switch to the argument tab and maintain the full path name of your
project as a parameter. Put the parameter in double-quotes.
I agree, these are Run Configurations and you're asking about configuration for debugging the app. Well, at least in PyCharm they apply to running through the debugger as well, they're actually called Run/Debug Configurations.
Maybe the same applies to Eclipse as well, so IMHO it's worth to locate this tab in your Eclipse version and configure in it the arguments you desire, then check if they apply in the debugger.
I am developing an App Engine project on Windows using Eclipse and Python 2.5 and Django 0.96. Everything in my app, including Django, is working nicely.
My problems arise when I try to use command line. For example, I'm told that if I want to clear the local datastore I can enter "python manage.py reset" but when I do so the response is "python: can't open file 'manage.py'".
I feel as if I have missed a configuration step. I have checked my system variables and "Path" includes "C:\Python25" (which I had added manually) but nothing Django or App Engine related. My .py extension is associated with C:\Python25\python.exe.
In my quest to solve this, and in trying to understand what manage.py is, I see that I might have had to create a Django project using "django-admin.py startproject [myproject]" but because everything works nicely from Eclipse I'm not sure if this is necessary now. In any case, if I try to enter this from the command line I get "'django-admin.py' is not recognized..."
Please, what am I missing?
If you're using Django 0.96 templates within a 'normal' App Engine app, then manage.py isn't involved at all.
/path/to/dev_appserver.py --clear_datastore .
is what you want, assuming you're CD'd to the root of your app.