Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CPkForeignKey #3

Open
Arisophy opened this issue Feb 16, 2021 · 0 comments
Open

CPkForeignKey #3

Arisophy opened this issue Feb 16, 2021 · 0 comments

Comments

@Arisophy
Copy link
Owner

Arisophy commented Feb 16, 2021

Need to make CpkForeignKey to treate grandchild records.

# GrandChild Model (CpkModel)
#   composite primary key: company_id, country_code, office_code
class CompanyBranchOffice(CPkModel):
    company_branch = CPkForeignKey(
        CompanyBranch,
        primary_key=True,       # for CompositePK
        on_delete=models.CASCADE)
    office_code = models.CharField(
        max_length=100,
        primary_key=True,       # for CompositePK
    )
    name = models.CharField(max_length=100)
    established_date = models.DateField()

    class Meta:
        managed = False  # for CompositePK
        db_table = 'CompanyBranchOffice'
        unique_together = (('company_branch', 'office_code'),)  # for CompositePK 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant