admin(22)
-
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 -
Djang Admin widget 셋팅
formfield_overrides = { models.CharField: {'widget': forms.TextInput(attrs={'size': 1})}, models.TextField: {'widget': forms.Textarea(attrs={'rows': 1,'cols': 15})}, models.BooleanField: {'widget': forms.CheckboxInput(attrs={'value': 12})}, } widget 종류 'Media', 'MediaDefiningClass', 'Widget', 'TextInput', 'NumberInput', 'EmailInput', 'URLInput', 'PasswordInput', 'HiddenInput', 'MultipleHiddenInp..
2021.02.04 -
Django Admin 함수 오버라이딩
get_queryset(self, request)를 super(ImageAdmin, self).get_queryset(request)로 변경하면 됨 @admin.register(Image) class ImageAdmin(admin.ModelAdmin) : list_display = ['id','file'] inlines = [BoxInline] def get_queryset(self, request): train.updateImage() return super(ImageAdmin, self).get_queryset(request)
2021.01.31