Skip to content

Instantly share code, notes, and snippets.

View Sanyambansal76's full-sized avatar
🎯
Focusing

Sanyam Bansal Sanyambansal76

🎯
Focusing
View GitHub Profile
@Sanyambansal76
Sanyambansal76 / local_settings.py
Created October 8, 2018 13:51 — forked from rochacbruno/local_settings.py
Django Profiling Middleware with hotshot or Cprofile
MIDDLEWARE_CLASSES = MIDDLEWARE_CLASSES + (
'yourapp.middleware.ProfileMiddleware',
'yourapp.middleware.CProfileMiddleware'
)
@Sanyambansal76
Sanyambansal76 / sql_replace_in_django_orm.py
Created May 1, 2018 10:17 — forked from simonw/sql_replace_in_django_orm.py
How to use the SQL replace function in a Django ORM query
from django.db.models import F, Func, Value
from myapp.models import MyModel
# Annotation
MyModel.objects.filter(description__icontains='\r\n').annotate(
fixed_description=Func(
F('description'),
Value('\r\n'), Value('\n'),
function='replace',
)