summaryrefslogtreecommitdiff
path: root/ishtar_common/models_common.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2021-09-01 17:58:56 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2022-12-12 12:20:58 +0100
commit3b671732319aa14f194821a8f547ae280e1e0648 (patch)
treeaa16f6f20916eecc7a99d9eed661d8bd1ddf9522 /ishtar_common/models_common.py
parente416f8d0702e2f3f981b50aebc08c67f7034d6a1 (diff)
downloadIshtar-3b671732319aa14f194821a8f547ae280e1e0648.tar.bz2
Ishtar-3b671732319aa14f194821a8f547ae280e1e0648.zip
Migration to Django 2.2 - missing on_delete - django.urls import reverse
Diffstat (limited to 'ishtar_common/models_common.py')
-rw-r--r--ishtar_common/models_common.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py
index 22244e4e2..6b137f2fd 100644
--- a/ishtar_common/models_common.py
+++ b/ishtar_common/models_common.py
@@ -31,7 +31,7 @@ from django.core.cache import cache
from django.core.exceptions import ObjectDoesNotExist
from django.core.files import File
from django.core.serializers import serialize
-from django.core.urlresolvers import reverse, NoReverseMatch
+from django.urls import reverse
from django.core.validators import validate_slug
from django.db import connection
from django.db.models import Q, Count, Max
@@ -1878,7 +1878,9 @@ class Department(models.Model):
class Arrondissement(models.Model):
name = models.CharField("Nom", max_length=30)
- department = models.ForeignKey(Department, verbose_name="Département")
+ department = models.ForeignKey(
+ Department, verbose_name="Département", on_delete=models.CASCADE
+ )
def __str__(self):
return settings.JOINT.join((self.name, str(self.department)))
@@ -1886,13 +1888,15 @@ class Arrondissement(models.Model):
class Canton(models.Model):
name = models.CharField("Nom", max_length=30)
- arrondissement = models.ForeignKey(Arrondissement, verbose_name="Arrondissement")
+ arrondissement = models.ForeignKey(
+ Arrondissement, verbose_name="Arrondissement", on_delete=models.CASCADE
+ )
def __str__(self):
return settings.JOINT.join((self.name, str(self.arrondissement)))
-class TownManager(models.GeoManager):
+class TownManager(models.Manager):
def get_by_natural_key(self, numero_insee, year):
return self.get(numero_insee=numero_insee, year=year)
@@ -2114,7 +2118,11 @@ class Address(BaseHistorizedItem):
)
town = models.CharField(_("Town (freeform)"), max_length=150, null=True, blank=True)
precise_town = models.ForeignKey(
- Town, verbose_name=_("Town (precise)"), null=True, blank=True
+ Town,
+ verbose_name=_("Town (precise)"),
+ null=True,
+ blank=True,
+ on_delete=models.SET_NULL,
)
country = models.CharField(_("Country"), max_length=30, null=True, blank=True)
alt_address = models.TextField(_("Other address: address"), blank=True, default="")
@@ -2802,6 +2810,7 @@ class GeoItem(models.Model):
verbose_name=_("Spatial Reference System"),
blank=True,
null=True,
+ on_delete=models.PROTECT
)
point = models.PointField(_("Point"), blank=True, null=True, dim=3)
point_2d = models.PointField(_("Point (2D)"), blank=True, null=True)