django(66)
-
Django queryset distinct
queryset에서 'char' 컬럼에 대해서 distinct 적용 chares = list(set(boxes.values_list('char', flat=True).distinct()))
2021.02.20 -
Django PostgreSQL 연동시 에러
connection 정보중 일부가 정확하지 않아서 생긴 문제 conn = _connect(dsn, connection_factory=connection_factory, **kwasync) django.db.utils.OperationalError
2021.02.19 -
Django filter 특징
BinaryField는 filter 적용 안됨 null은 ''로 인식됨 : filter(a='')
2021.02.17 -
Django Admin change_form.html에 버튼 추가 및 저장시 custom 작업 수행
{% block submit_buttons_bottom %} {{ block.super }} {% endblock %} def response_change(self, request, obj): if "_gotoTrainedBoxes" in request.POST or "_gotoTrainedBoxes(include Image)" in request.POST : if "_gotoTrainedBoxes(include Image)" in request.POST : Trained_Image.createImageData(obj) opts = self.model._meta msg = format_html('The Trained_Image “{}” was changed successfully.', obj.id) se..
2021.02.12 -
Django Admin list_display에 custom link 추가
list_display = ['id','linkImage',] def linkImage(self, obj) : url = reverse('admin:ocr_trained_image_change', args=[obj.image]) return format_html("{}",url,obj.image) linkImage.short_description = 'Image' list_display = ['id','popup_gantt','manager'] def popup_gantt(self, obj) : return format_html("{}", obj.id,obj.name)
2021.02.11 -
Django DB에 이미지 저장 및 가져오기
image_data = models.BinaryField(null=True) box.image_data = base64.b64encode(output.getvalue()) if self.image_data != None : return format_html("",self.image_data.decode('UTF-8'))
2021.02.11