fieldName = models.ForeignKey(RelatedModel, on_delete=models.CASCADE)
      Python language logo
      your recipe card header background

      Foreign Key Field

      Django Public Recipes

      The code above creates a foreign key in the RelatedModel to link to the current model. When the related model is deleted, the related model's on_delete attribute is invoked, which in turn calls the cascade method on the current model.

      Library: django

      Shortcut: django.field.foreignkey

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.