Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ERROR: Invalid Token. Expected stringEnd but found tag start "{%" instead

I've been getting this error message for a while now, but actually the code works fine and runs as expected, the line causing the error is this:

templates/users/dashboard.html->

<link rel="stylesheet" href="{% static 'css/dashboard.css' %}">

when i remove the quotations i get a deferent error:

<link rel="stylesheet" href={% static 'css/dashboard.css' %}>

ERROR: Invalid Token. Expected stringStart but found tag start "{%" instead.

when i completely remove the line i get the same erro on the first tag with href:

<a href="{% url 'login' %}">Logout</a>

ERROR: Invalid Token. Expected stringEnd but found tag start "{%" instead.

i suspect that its a vscode issue, because the code runs flawlessly, and it only catches the error when i clean the code(format), so as long as i open vscode and never hit (ctrl+shidt+f) i dont get the error message, is there a solution for this?

like image 898
Hannon qaoud Avatar asked Jul 24 '26 22:07

Hannon qaoud


2 Answers

I got the same error. The problem was a VS Code extension, in my case it was "Django Template Support" from junstyle.

If anyone has the same problem, try to deactivate all your extensions in VS Code, restart the editor and try again.

like image 135
DevNick Avatar answered Jul 26 '26 14:07

DevNick


Had the same behaviour today in vs code. Problem was a conflict within the django extensions in vs code, which I had installed. You may check your django extensions.

like image 20
Markus Avatar answered Jul 26 '26 13:07

Markus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!