Sử dụng đoạn mã sau:Lỗi sử dụng một lĩnh vực lớp cơ sở trong lớp con unique_together tùy chọn meta
class Organization(models.Model):
name = models.CharField(max_length="100",)
alias = models.SlugField()
...
class Division(Organization):
parent_org = models.ForeignKey(Organization)
class Meta:
unique_together=['parent_org', 'alias']
...
Cố gắng syncdb cho tôi lỗi này:
Error: One or more models did not validate:
organizations.division: "unique_together" refers to alias. This is not in the
same model as the unique_together statement.
Any help is appreciated,
Cảm ơn,
Eric
Bạn có thể giải thích yêu cầu nhiều hơn, không thể hiểu nhu cầu kế thừa tổ chức và có ngoại khóa cho cùng một mô hình cơ sở. –
Đó là một mối quan hệ cha-con đơn giản mà một tổ chức có thể có nhiều bộ phận, một bộ phận là một loại tổ chức chuyên môn. –