Debugging django templates in pycharm - python

I've set break points in the template and i run the server but pycharm doesn't seem to pick up the breakpoints for the template but only the python files. Does anyone know how to fix this?

From Pycharm 2017.1
Prerequisite
Django is specified as the project template language.
To do that, open the Project Settings dialog, under the Project Settings select page Python Template Languages, select project where the templates reside, and then choose Django from the Template Language drop-down list.
Debugging a Django template
To debug a Django template, follow these general steps
Place breakpoints in the desired lines of the Django templates:
Launch Django server in the Debug mode.
This is how it's done:
On the main menu, choose Run | Edit Configurations.
If the desired Django Server run/debug configuration exists, select it, otherwise create a new one, as described in the section Creating and Editing Run/Debug Configuration.
Then click the button on the main toolbar, or press ⌃D.
PyCharm will open the template in your browser, and suspend at the breakpoints you've set.
The Debugger session starts, and Debug tool window appears.
In the Debug tool window, you can:
Examine the rendering contexts in the Variables pane.
Step through the breakpoints defined within the Django template.
Use the debugging console.
If you want to trace back exceptions that are raised in course of template debugging, open Breakpoints dialog, and in the Django Exception Breakpoints tab, select the check box Suspend.
Debugging Jinja and Mako templates is not supported.
https://www.jetbrains.com/help/pycharm/2017.1/debugging-django-templates.html

Related

Multiple Django Projects using IIS but Getting Blank Page on Second Site

I'm running two django projects in IIS with wfastcgi enabled. The first django project is running without an issue but the second project displays a blank page (code 200) returned.
Second Project Info:
A virtual folder, within it's own application pool in IIS, is created to host the second project. The second project was created in an python environment folder. The second project runs from django using python manage.py runserver 0.0.0.0:8080, but displays a blank page when browsing to the virtual folder page.
The root folder was granted with "everyone" full control access to all sub-folders
for the second project, wfastcgi application and handler is pointing to the virtual environment python and wfastcgi file correctly.
Can you have two wfastcgi applications and handlers "Second Python FastCGI"
C:\project_folder\project_env\Scripts\python.exe|C:\project_folder\project_env\lib\site-packages\wfastcgi.py"
I wanted them separate so that two developers don't interfere with each others work, but they need to run within the same server and port.
I resolved the problem by editing the web.config file and removing the static handler from it. The static handler was being used instead of the FastCgiModule handler. The static handler should be moved below the FastCgiModule.

How to do Debugging Test Cases of Robot Framework in Pycharm?

I am unable to debug any test case of Robot Framework in Pycharm Community version. Is there any simple way to start the debugging through breakpoints like eclipse?
I tried to set up with the instruction provided here : https://intellij-support.jetbrains.com/hc/en-us/community/posts/360007703060-Debugging-python-code-when-running-Robot-Framework-tests but its not working.
Open Pycharm and go to right side and open edit Configuration where you can edit Run/Debug configuration
Click on Plus icon showing at top left corner, Select Robot Framework and Set Configuration as per defined in Image and save configuration. Note: Target .robot or folder to run should be your project\testcase path
Select saved setting for debug Robot file
Put debugger from where you want to debug and click on debug icon. It will work.

Rendering of django-bootstrap-datepicker-plus widget on pythonanywhere

I wrote a very simple django application and uploaded it to pythonanywhere. Through this form (and its base template) I'd like to allow the user to setting date and time using django-bootstrap-datepicker-plus (and django-bootstrap3).
The date-picker widget works fine on my localhost in debugging mode (see a detail of my [local] webpage in this figure), i.e. I can click on the calendar icon to display the calendar widget. My problem is that on the pythonanywhere server the widget cannot be displayed (i.e., the calendar icon is missing and when I click on the rightmost part of the date-time entry field, nothing happens).
I am using the same source code (pulling the latest versions of my github repository). Moreover, the virtual environment on pythonanywhere is set through a requirement.txt file obtained by [pip] freezing my local environment (thus, I am also using the same python packages).
The most likely issue is that you're not serving the static files that are necessary for the widget to work. Check your browser requests in the developer tools to see if you're getting 404s for any resources that may be used by the widget. If they are 404ing, have a look at the PythonAnywhere and Django docs for how to properly serve static resources.

Configuring an Existing Django Project on Pycharm

I´m starting to use Django with Pycharm IDE and have succesfully configured my first project.
However, I tried to add a new existing project to Pycharm and when trying to change the Run Configuration to use the manage.py of my secondProject(GuatepediaLocal), I don´t get an option to select it on the dropdown menu. When I try to run the project, it keeps running the PollSite manage.py runserver and not GuatepediaLocal´s manage.py runserver
Can anyone help me to solve this issue and configure an already existing Django Project on pycharm?
After some research I found that on the settings window of Pycharm I must add Django support to my project
That enabled the project on the dropdown menu. After that, I just added on the enviroment variables the correct path to my project´s settings.py.
Hope this helps someone someday :)
Open edit configuration wizard.
Menu > Run > Edit Configuration
Add new configuration by selecting the Django server from the left top button (button look like + sign). Look like below. Plus sign top left.
If you don't configure the Django setting. It will show you the fix button to fix the Django Setting. Django Setting looks like this. You can manually set these setting by navigating like this.
File > Settings > Language and Framework > Django
Django Setting wizard looks like this.
set the project path, manage.py file and settings.py file.

Pydev error while creating new django project

I keep getting this error every time i create a new django project using titanium (eclipse) with pydev.
Actually, it did create the file settings.py
I wonder what make this error and how to fix it?
It's really a PyDev issue with Django 1.4. A new release (2.5.0) will be done later this week properly supporting the layout changes in Django 1.4.
You can still use the project created this way, but you have to do some manual things:
Move the contents inside of the folder that was created to your module (this was the structural change done in django 1.4)
The settings.py won't have the details you entered in the wizard (i.e.: manually edit the settings.py)
In the project django's properties (right click project > properties and check the django properties page), you have to put the proper settings to the settings module and manage.py.
I updated my pydev today to the last version and now it seems to be working beautifully...

Categories