문제

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>
도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top