This file contains hidden or 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
class ShopAdmin(admin.ModelAdmin): | |
formfield_overrides = { | |
PointField: {"widget": GoogleMapPointWidget(attrs={ | |
'display_raw': True, | |
'zoom': 20, | |
'default_lat': 47.710046956003481, | |
'default_lng': 42.363638094275998 | |
})}, | |
} |
This file contains hidden or 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
import json | |
from django.contrib.gis.geos import GEOSGeometry, Point, Polygon, MultiPolygon | |
from django.utils.translation import ugettext_lazy as _ | |
from rest_framework import serializers | |
EMPTY_VALUES = (None, '', [], (), {}) | |
DEFAULT_SRID = 4326 | |
This file contains hidden or 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
class SerializerSchemaMixin(object): | |
""" | |
Will be used on different actions when we need to use different serializer classes on different actions. | |
For example: | |
serializer_schema = { | |
'create': AnyCreateSerializer, | |
'retrieve': AnyDetailSerializer, | |
'update': AnyUpdateSerializer, | |
'search': AnyListSerializer, |
This file contains hidden or 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 import transaction | |
from apps.my_app.tasks import send_email_notification | |
from apps.my_app.models import MyModel | |
@transaction.atomic | |
def example_view(request): | |
... | |
obj = MyModel.objects.create(...) | |
... |
This file contains hidden or 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
./clean_backups.sh "20 days" subdirectory | |
./clean_backups.sh "30 days" daily | |
./clean_backups.sh "365 days" monthly |
This file contains hidden or 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
function getCookie(name) { | |
var cookieValue = null; | |
if (document.cookie && document.cookie !== '') { | |
var cookies = document.cookie.split(';'); | |
for (var i = 0; i < cookies.length; i++) { | |
var cookie = jQuery.trim(cookies[i]); | |
// Does this cookie string begin with the name we want? | |
if (cookie.substring(0, name.length + 1) === (name + '=')) { | |
cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); | |
break; |