장고 프로젝트와 관련된 데이터베이스를 정규화하고 다른 테이블로 필드를 이동합니다. 구현 과정의 일부로, 실제로 열을 제거하기 전에 새 테이블을 추가 한 후 이전 특성을 사용하려고하면 내 동료에게 사용 중단 경고를 표시하고 싶습니다.django 모델의 필드 사용 중단
class Asset(Model):
model = models.CharField(max_length=64, blank=True, null=True)
part_number = models.CharField(max_length=32, blank=True, null=True) # this will be a redundant column to be deprecated
company = models.ForeignKey('Company', models.CASCADE, blank=True, null=True) # this will be a redundant column to be deprecated
# other database fields as attributes and class methods
나의 이해는 내가 어딘가에 클래스 warnings.warn('<field name> is deprecated', DeprecationWarning)
의 라인을 따라 뭔가를 추가해야합니다,하지만 난 그것을 어디에 추가 할 것입니다?
필드를 속성으로 변경하고 거기에서 경고를 처리하고 가능한 경우 적절한 값을 반환 할 수 있습니다. –