fieldName = models.OneToOneField(relatedModel, on_delete=models.CASCADE)

      Python language logoDjango 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.

      Shortcut: django.field.one_to_one

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.