Last active
June 28, 2022 12:25
-
-
Save walkness/a7e6529376a53297231c287db55d2f02 to your computer and use it in GitHub Desktop.
Django regex replace for PostgreSQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db.models import Func, F, Value | |
from images.models import Image | |
Image.objects.all().update(original_filename=Func(F('file'), Value('^.*\/(.*)$'), Value('\\1'), function='regexp_replace')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment