django(66)
-
tile cannot extend outside image
crop의 값이 잘못들어간 경우 발생\ 잘못들어간 경우, size에 '0'이 존재 image = pil.Image.open(trainedImage.file) output = io.BytesIO() boxImage = image.crop((box.x,box.y,box.width,box.height))(X) print(boxImage.size) boxImage = image.crop((box.x,box.y,box.x+box.width,box.y+box.height))(O) print(boxImage.size) output.close()
2021.02.11 -
Django Admin list_editable save 호출 함수
변경된 row 한개씩 처리 def save_model(self,request,obj,form,change) : if(obj.lang != Image.objects.get(id=obj.id).lang) : train.createBox(obj) super(ImageAdmin,self).save_model(request,obj,form,change) 변경된 row 전체 처리 def save_formset(self,request,form,formset,change) : print('save_formset') super(ImageAdmin,self).save_formset(request,form,formset,change)
2021.02.10 -
Django Admin widget 셋팅 주의점
적용안됨 : field.widget.attrs['size'] = 5 적용됨 : field.widget = forms.TextInput(attrs={'size': 5}) def formfield_for_dbfield(self, db_field, **kwargs): field = super(ImageAdmin, self).formfield_for_dbfield(db_field, **kwargs) if db_field.name in ('lang') : field.widget = forms.TextInput(attrs={'size': 5}) #field.widget.attrs['size'] = 5 return field
2021.02.07 -
Django Admin 함수
# 목록에서 쿼리 결과 가져오는 함수 def get_queryset(self, request) : return super(ImageAdmin, self).get_queryset(request) # 목록에서 delete action 수행을 후킹하는 함수 def get_deleted_objects(self, objs, request): return super(ImageAdmin, self).get_deleted_objects(objs, request)
2021.02.05 -
Django Admin 템플릿에서 static 사용시 주의점
먼저 load를 해주지 않으면 인식이 안됨 setttings.py에서 관련정보를 가져오는 것 같음 {% extends 'admin/change_form.html' %} {% load static %} {% block canvas_start %}
2021.02.04 -
Django Built-in template tags and filters for문
VariableDescription forloop.counterThe current iteration of the loop (1-indexed) forloop.counter0The current iteration of the loop (0-indexed) forloop.revcounterThe number of iterations from the end of the loop (1-indexed) forloop.revcounter0The number of iterations from the end of the loop (0-indexed) forloop.firstTrue if this is the first time through the loop forloop.lastTrue if this is the l..
2021.02.04