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

Path mappings not working with Python/Django project

Offen
#241 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
TypeScript
Sterne
447
Forks
76
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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
```

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne mit den pathMappings- und webRoot-Einträgen in .vscode/launch.json und vergleiche sie anschließend mit der PathConversion-Ausgabe der Debug Console für /map/ und die statischen Dateien. Reproduziere die Django/Jinja2-Seite und überprüfe, dass die eingebundene www/jinja/map/js/map.js in den aufgeführten lokalen Pfad aufgelöst wird, während die bestehenden statischen Zuordnungen weiterhin funktionieren.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
django, python, vscode
Bereich
devtools
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.