Question

I'm using pycharm on a Django project.

In my templates, I have some embedded JS. And in a couple places, I'm using Django template tags in the JS. And that is causing PyCharm to mark all the JS after these template tags as a syntax error. I know it can't parse the template code, but there HAS to be a better option than trying to read my JS with Pycharm error annotations all over it.

Here is an example of the kind of stuff I'm talking about:

<script type="text/javascript">

details = {
  'foo': 'bar',

  {% if blah %}
    'blah': {{ blah }},
  {% endif %}
}

</script>
Was it helpful?

Solution

Turns out, you need to tell PyCharm you're using Django templates. It's in project setting under "python template languages".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top