django(66)
-
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 Model ForeignKey
생성할때는 객체를 넘여야 함 조회할때는 id값만 있어도 됨
2021.01.31 -
Cannot assign "25": "Box.image" must be a "Image" instance.
Model의 ForeignKey는 값이 아닌, 객체를 대입해야 함 self.image = image(X) self.image = Image.objects.get(id=image)(O)
2021.01.31 -
object has no attribute '_state'
Model 생성자 __init__ 오버로딩 에러 생성자 오버로딩은 안되는걸로
2021.01.31 -
Django __init__() takes 1 positional argument but 2 were given
파라메터가 2개 필요한데, 1개만 전송됨
2021.01.31 -
Django Model에 instance 추가
import glob import Image def updateImage() : images = [] images += glob.glob('./../*.tiff') images += glob.glob('./../*.png') for image in images : if Image.objects.filter(file=image).count() == 0 : Image(file=image).save()
2021.01.31