firefox-devtools / firefox-devtools/vscode-firefox-debug

Path mappings not working with Python/Django project

Open
#241 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
447
Forks
76
PR merge metrics
No merged PRs in 30d

Description

regards to: Debugger for FireFox v2.9.1

With Python/Django a URL maps to a path in an "app" folder. The HTML code is generated by Jinja2 template engine. I included a JS file into a Jinja2 template file:
````jinja
{% block javascript %}

{% include "map/js/map.js" %}

{% endblock javascript %}
````
The static JS files `assets\plugins\custom\leaflet\leaflet.bundle.js` is found by "vscode-firefox-debug", but the included JS file `map/js/map.js` is not.
The path structure is as followed:
```
${workspaceFolder}
|-- www
| |-- jinja
| |-- map
| |-- js
| |-- map.js
|-- static
|-- assets
|-- plugins
|-- custom
|-- leaflet
|-- leaflet.bundle.js
```
The URL `http://127.0.0.1:8000/map` is mapped in the Django project to the path `${workspaceFolder}\\www\\jinja\\map` and is working (shows the website).

The problem is, that the mapping with `${workspaceFolder}\\.vscode\\launch.json` is not working. My configuration is as followed:
```json
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Django",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}\\manage.py",
"args": [
"runserver",
"--noreload"
],
"django": true
},
{
"name": "JS",
"type": "firefox",
"firefoxExecutable": "D:\\Tools\\FirefoxPortable\\FirefoxPortable.exe",
"request": "launch",
"reAttach": true,
"url": "http://127.0.0.1:8000/",
"webRoot": "${workspaceFolder}",
"pathMappings": [
{
"url": "http://127.0.0.1:8000/map/(index)",
"path": "${workspaceFolder}\\www\\jinja\\map\\js\\map.js"
},
],
"skipFiles": [
"${workspaceFolder}\\static\\**\\*.js"
],
"log": {
"consoleLevel": {
"PathConversion": "Debug",
"default": "Error"
}
}
}
]
}
```
I also tried different paths, e.g. `${workspaceFolder}\\www\\jinja\\map\\js` or `${workspaceFolder}\\www\\jinja\\map`, and even `${workspaceFolder}\\www\\jinja\\map\\js\\index.html` with a dummy HTML file as workaround, which includes only the JS file. But in the status window for the debugger appears not the correct mapping, but `${workspaceFolder}\\map` (as the URL)

Output from Debug Console:
```
DEBUG|000.121|PathConversion: Converted url http://127.0.0.1:8000/static/assets/js/scripts.bundle.js to path ${workspaceFolder}\static\assets\js\scripts.bundle.js
DEBUG|000.122|PathConversion: Converted url http://127.0.0.1:8000/map/ to path ${workspaceFolder}\map\
DEBUG|000.123|PathConversion: Converted url http://127.0.0.1:8000/static/assets/plugins/custom/leaflet/leaflet.bundle.js to path ${workspaceFolder}\static\assets\plugins\custom\leaflet\leaflet.bundle.js
DEBUG|000.124|PathConversion: Converted url http://127.0.0.1:8000/static/assets/plugins/global/plugins.bundle.js to path ${workspaceFolder}\static\assets\plugins\global\plugins.bundle.js
```

Contributor guide

Open the contributing guide

Research direction

Start with the pathMappings and webRoot entries in .vscode/launch.json, then compare them with the Debug Console PathConversion output for /map/ and the static files. Reproduce the Django/Jinja2 page and verify that the included www/jinja/map/js/map.js resolves to its listed local path while the existing static mappings continue to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, python, vscode
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.