Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

django on_delete rules

from django.conf import settings
from django.contrib.auth import get_user_model
from django.db import models

def get_sentinel_user():
    return get_user_model().objects.get_or_create(username='deleted')[0]

class MyModel(models.Model):
    user = models.ForeignKey(
        settings.AUTH_USER_MODEL,
        on_delete=models.SET(get_sentinel_user),
    )
Comment

PREVIOUS NEXT
Code Example
Python :: how to store svgs in django image field with SVGAndImageFormField 
Python :: EMAIL_BACKEND where to read 
Python :: atan of number python 
Python :: conversion of int to a specified base number 
Python :: Get Dates Between Two Ranges 
Python :: Python regex emailadres no jpg 
Python :: Django pull from Google Sheets 
Python :: list all subdirectories up to a level 
Python :: find-squares-and-odd-numbers-in-the-given-list 
Python :: hi guys 
Python :: pandas corr get couple value 
Python :: numpy transpose shorthand 
Python :: how to join models from another app 
Python :: convert integer to string python 
Python :: python int rightpad with 0 
Python :: multiplication objects 
Python :: get first element of each group 
Python :: str.format() 
Python :: # print random number 
Python :: pandas dataframe how to store 
Python :: python online compiler with libraries 
Python :: auto reload exml odoo 13 
Python :: Flatten List in Python Using NumPy Ravel 
Python :: split x and y pandas 
Python :: how to find the index of a specific number in pythong? 
Python :: frozenset numbers in python 
Python :: Annotation graphique python 
Python :: Python NumPy atleast_1d Function Syntax 
Python :: odoo 15 documentation 
Python :: Python NumPy hstack Function Example with 2d array 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =