I've inherited a large number of files with direct links to static files like <img src="images/logo.png" />
when it should be <img src="{% static 'img/logo.png' %}" />
. Shy of writing my own script, is there a tool I can use to convert from static to dynamic links (are those the correct terms)? I'm using PyCharm too, if that has any tools I can use.
Asked
Active
Viewed 79 times
2

Nanor
- 2,400
- 6
- 35
- 66
2 Answers
1
Just use a regular expression. Search for this:
src="([^'"]+)"
Replace with this:
src="{% static '\1' %}"
Example: https://regex101.com/r/yJ7cO1/1

Wolph
- 78,177
- 11
- 137
- 148
-
1For IntelliJ, you need to use $ instead of \ to use the result of the previous regex. See http://stackoverflow.com/questions/1421797/regex-backreferences-in-intellij – Jesuisme Nov 10 '16 at 02:21
0
I hope your problem solved by above solution .... But think.... here if you want to change the some varibale in Pycharm .... Step... 1.
Right click on the variable that you want to change and go for **Refactor**
Pycharm

Mushahid Khan
- 2,816
- 1
- 19
- 32
-
Renaming of multiple variables is not available in HTML files with PyCharm. Even if it was, I would have to do it with every different instance which is basically what I'm trying not to do. – Nanor Jan 07 '16 at 14:05