Skip to content

Instantly share code, notes, and snippets.

@rcotrina94
Last active May 9, 2023 08:17
Show Gist options
  • Save rcotrina94/6f401a9454f22b6e23e8 to your computer and use it in GitHub Desktop.
Save rcotrina94/6f401a9454f22b6e23e8 to your computer and use it in GitHub Desktop.
Find and Replace Django static files from template
Find what:
`(href|src)="([a-zA-Z0-9/.-]+[^.html])"`
Replace with:
`$1=\"{% static "assets/$2" %}"`
@basola21
Copy link

basola21 commented May 9, 2023

I find it better to replace with single quote ' rather than double quotes " since most HTML templates use the double quotes for the html file here is a modified version

Find what:
(href|src)="([a-zA-Z0-9/.-]+[^.html])"

Replace with:
$1=\"{% static 'assets/$2' %}"

Thanks though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment