2010-03-04 3 views
0

SAAS의 계정은 Account(models.Model)입니다. 다음은 좋은 생각일까요?Django 다중 테넌트 아키텍처 - 모든 모델에 tennant_id에 대한 참조가 있어야합니다.

class MyModel(models.Model): 
    account = models.ForeignKey(Account) 
    spam = models.CharField(max_length=255) 

class MyOtherModel(models.Model): 
    # The next attribute `account` is the line in question. 
    # Should it be included even though mymodel.account can get the same value? 
    # The architecture could change later, and I might regret not including it, 
    # but I can't think of many reasons why, other than filtering a list out of 
    # this model like MyOtherModel.objects.filter(account=some_account).all() 
    # Are there other considerations? 
    account = models.ForeignKey(Account) 
    mymodel = models.ForeignKey(MyModel) 
    eggs = models.CharField(max_length=255) 

답변

1

지금 사용하지 않으려는 경우 제외하십시오. 나중에 필요한 경우 리팩토링하여 지금 필요한 코드를 작성하십시오. 거기에 몇 가지 도구 스키마 변경을 더 고통없이 만들 수 있습니다. South은 훌륭한 예입니다. 많은 상황에서 잘 작동하고 성숙해지며 그 뒤에 큰 커뮤니티 지원이 있습니다. django-evolution 다른 옵션입니다 잠시 동안 주변에 있었지만 개발이 중단되었지만 일부 사람들이 여전히 선호하는 접근 방식을 제공합니다.

관련 문제