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 channels | |
import time | |
import redis | |
import Queue | |
import select | |
from redis.exceptions import ( | |
ConnectionError, | |
TimeoutError, | |
) | |
from channels.log import setup_logger |
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
# Есть стандартный способ создавать динамические формы в django: | |
# http://jacobian.org/writing/dynamic-form-generation/ | |
# Но если использовать такую форму в админке, динамические поля не будут показаны, тк BaseModelAdmin.get_fieldsets использует свойство # base_fields класса формы, а не fileds экземпляра. | |
# Я нашел такое решение (В данном случае это Inline, но можно использовать где угодно): | |
class AndswerInline(admin.StackedInline): | |
form = AndswerInlineForm | |
def __init__(self, *args, **kwargs): |
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 os | |
from django.core.files.uploadedfile import InMemoryUploadedFile, TemporaryUploadedFile | |
from PIL import Image | |
from PIL.ExifTags import TAGS | |
from cStringIO import StringIO | |
def orientation_rotation(im): | |
#take pil Image insctance and if need rotate it | |
orientation = None |