True면 null허용 - Database에 Null값저장여부
True면 blank허용, Field.null은 False True 인 경우 필드를 비워 둘 수 있습니다. 이것은 null과 다른데요. null은 순전히 데이터베이스와 관련이있는 반면 blank는 유효성 검사와 관련됩니다.
YEAR_IN_SCHOOL_CHOICES = [ ('FR', 'Freshman'), ('SO', 'Sophomore'), ('JR', 'Junior'), ('SR', 'Senior'), ('GR', 'Graduate'), ]
Database column의 이름
True면 필드에 대한 database index를 생성한다.
이 field의 index에 대한 tablespace name
default값
False면 Admin, ModelForm에 보여지지 않는다. model validation또한 skip. default로 True.
The error_messages argument lets you override the default messages that the field will raise.
Form field에 extra help
True - primary key
If True, this field must be unique throughout the table.
Set this to the name of a DateField or DateTimeField to require that this field be unique for the value of the date field.
Like unique_for_date, but requires the field to be unique with respect to the month.
Like unique_for_date and unique_for_month.
A human-readable name for the field.
A list of validators to run for this field.
쓸데없이 왜 이렇게 많은 거야!
if field.name == 'code_kind': print(f"{field.name} <- MARO_DOMAIN_CD") print(f"{field.attname} <- attname") print("ForeignKey : {}.".format(isinstance(field, models.ForeignKey))) print("ManyToManyField : {}.".format(isinstance(field, models.ManyToManyField))) print("OneToOneField : {}.".format(isinstance(field, models.OneToOneField))) print("Field : {}.".format(isinstance(field, models.Field))) if isinstance(field, models.ForeignKey): print(f"field.deconstruct 3:{ field.deconstruct()[3] }") print(item.code_kind.__class__.objects.get(code_kind='MARO_DOMAIN_CD')) print(item.code_kind.__class__.objects.get(code_kind='LANG_CD')) print(f"field.deconstruct:{ field.deconstruct() }") print(f"target_field:{ field.target_field }") print(f"db_constraint:{ field.db_constraint }") print(f"field.db_column(현 테이블의 column명):{ field.db_column }") pass print(field.key) print(item.code_kind) print(type(item.code_kind)) print(item.code_kind.objects.get(code_kind='MARO_DOMAIN_CD')) item.code_kind = 'MARO_DOMAIN_CD' else: print(field.name)
Returns a 4-tuple with enough information to recreate the field:
This method must be added to fields prior to 1.7 to migrate its data using Migrations.