Django One to One Field



    Django Public Recipes

    The code declares a new OneToOneField, called fieldName, in the model RelatedModel. The on_delete attribute specifies that when a user deletes an entry in RelatedModel, fieldName will be automatically updated to reflect the deletion.

    Library: django

    Shortcut: django.field.one_to_one

    fieldName = models.OneToOneField(relatedModel, on_delete=models.CASCADE)
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.