django2.2: add default mandatory on_delete on OneToOneField

This commit is contained in:
Antoine Bartuccio 2019-10-05 19:09:15 +02:00
parent 4dadb1dbc0
commit 6cc234e8d3
Signed by: klmp200
GPG Key ID: E7245548C53F904B
7 changed files with 25 additions and 8 deletions

View File

@ -352,6 +352,7 @@ class Operation(models.Model):
null=True, null=True,
blank=True, blank=True,
default=None, default=None,
on_delete=models.CASCADE,
) )
class Meta: class Meta:

View File

@ -96,7 +96,9 @@ class Club(models.Model):
blank=True, blank=True,
on_delete=models.SET_NULL, on_delete=models.SET_NULL,
) )
page = models.OneToOneField(Page, related_name="club", blank=True, null=True) page = models.OneToOneField(
Page, related_name="club", blank=True, null=True, on_delete=models.CASCADE
)
class Meta: class Meta:
ordering = ["name", "unix_name"] ordering = ["name", "unix_name"]

View File

@ -51,7 +51,7 @@ class Customer(models.Model):
is used by other accounting classes as reference to the customer, rather than using User is used by other accounting classes as reference to the customer, rather than using User
""" """
user = models.OneToOneField(User, primary_key=True) user = models.OneToOneField(User, primary_key=True, on_delete=models.CASCADE)
account_id = models.CharField(_("account id"), max_length=10, unique=True) account_id = models.CharField(_("account id"), max_length=10, unique=True)
amount = CurrencyField(_("amount")) amount = CurrencyField(_("amount"))
recorded_products = models.IntegerField(_("recorded product"), default=0) recorded_products = models.IntegerField(_("recorded product"), default=0)
@ -727,7 +727,10 @@ class Eticket(models.Model):
""" """
product = models.OneToOneField( product = models.OneToOneField(
Product, related_name="eticket", verbose_name=_("product") Product,
related_name="eticket",
verbose_name=_("product"),
on_delete=models.CASCADE,
) )
banner = models.ImageField( banner = models.ImageField(
upload_to="etickets", null=True, blank=True, verbose_name=_("banner") upload_to="etickets", null=True, blank=True, verbose_name=_("banner")

View File

@ -421,7 +421,9 @@ class ForumUserInfo(models.Model):
user, such as the favourite topics, the signature, and so on... user, such as the favourite topics, the signature, and so on...
""" """
user = models.OneToOneField(User, related_name="_forum_infos") user = models.OneToOneField(
User, related_name="_forum_infos", on_delete=models.CASCADE
)
last_read_date = models.DateTimeField( last_read_date = models.DateTimeField(
_("last read date"), _("last read date"),
default=datetime( default=datetime(

View File

@ -37,7 +37,10 @@ from club.models import Club
class Launderette(models.Model): class Launderette(models.Model):
name = models.CharField(_("name"), max_length=30) name = models.CharField(_("name"), max_length=30)
counter = models.OneToOneField( counter = models.OneToOneField(
Counter, verbose_name=_("counter"), related_name="launderette" Counter,
verbose_name=_("counter"),
related_name="launderette",
on_delete=models.CASCADE,
) )
class Meta: class Meta:

View File

@ -39,7 +39,10 @@ class Stock(models.Model):
name = models.CharField(_("name"), max_length=64) name = models.CharField(_("name"), max_length=64)
counter = models.OneToOneField( counter = models.OneToOneField(
Counter, verbose_name=_("counter"), related_name="stock" Counter,
verbose_name=_("counter"),
related_name="stock",
on_delete=models.CASCADE,
) )
def __str__(self): def __str__(self):

View File

@ -80,7 +80,7 @@ class Trombi(models.Model):
show_profiles = models.BooleanField( show_profiles = models.BooleanField(
_("show users profiles to each other"), default=True _("show users profiles to each other"), default=True
) )
club = models.OneToOneField(Club, related_name="trombi") club = models.OneToOneField(Club, related_name="trombi", on_delete=models.CASCADE)
objects = TrombiManager() objects = TrombiManager()
availables = AvailableTrombiManager() availables = AvailableTrombiManager()
@ -117,7 +117,10 @@ class TrombiUser(models.Model):
""" """
user = models.OneToOneField( user = models.OneToOneField(
User, verbose_name=_("trombi user"), related_name="trombi_user" User,
verbose_name=_("trombi user"),
related_name="trombi_user",
on_delete=models.CASCADE,
) )
trombi = models.ForeignKey( trombi = models.ForeignKey(
Trombi, Trombi,