Skip to content

Commit

Permalink
Django 2 compatibility changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Rikuoja committed Nov 14, 2019
1 parent 9e62f6a commit 0a335d7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
11 changes: 1 addition & 10 deletions munigeo/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ class AdministrativeDivisionGeometry(models.Model):
division = models.OneToOneField(AdministrativeDivision, related_name='geometry', on_delete=models.CASCADE)
boundary = models.MultiPolygonField(srid=PROJECTION_SRID)

objects = models.GeoManager()


@python_2_unicode_compatible
class Municipality(models.Model):
Expand All @@ -110,7 +108,6 @@ class Municipality(models.Model):
division = models.OneToOneField(AdministrativeDivision, null=True, db_index=True,
related_name='muni', on_delete=models.CASCADE)

objects = models.Manager()

def __str__(self):
return self.name
Expand All @@ -123,7 +120,6 @@ class Plan(models.Model):
origin_id = models.CharField(max_length=20)
in_effect = models.BooleanField(default=False)

objects = models.GeoManager()

def __str__(self):
effect = "in effect"
Expand Down Expand Up @@ -161,8 +157,6 @@ class Address(models.Model):
location = models.PointField(srid=PROJECTION_SRID,
help_text="Coordinates of the address")

objects = models.GeoManager()

modified_at = models.DateTimeField(auto_now=True,
help_text='Time when the information was last changed')

Expand All @@ -183,13 +177,11 @@ class Meta:
@python_2_unicode_compatible
class Building(models.Model):
origin_id = models.CharField(max_length=40, db_index=True)
municipality = models.ForeignKey(Municipality, db_index=True)
municipality = models.ForeignKey(Municipality, db_index=True, on_delete=models.CASCADE)
geometry = models.MultiPolygonField(srid=PROJECTION_SRID)

addresses = models.ManyToManyField(Address, blank=True)

objects = models.GeoManager()

modified_at = models.DateTimeField(auto_now=True,
help_text='Time when the information was last changed')

Expand Down Expand Up @@ -220,7 +212,6 @@ class POI(models.Model):
zip_code = models.CharField(max_length=10, null=True, blank=True)
origin_id = models.CharField(max_length=40, db_index=True, unique=True)

objects = models.GeoManager()

def __str__(self):
return "%s (%s, %s)" % (self.name, self.category.type, self.municipality)
7 changes: 4 additions & 3 deletions munigeo/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
'django.contrib.staticfiles',
)

ALWAYS_MIDDLEWARE_CLASSES = (
ALWAYS_MIDDLEWARE = [
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
]

settings.configure(
DATABASES={
'default': {
Expand All @@ -34,7 +35,7 @@
TEMPLATE_DEBUG=False,
ALLOWED_HOSTS=[],
INSTALLED_APPS=ALWAYS_INSTALLED_APPS + CUSTOM_INSTALLED_APPS,
MIDDLEWARE_CLASSES=ALWAYS_MIDDLEWARE_CLASSES,
MIDDLEWARE=ALWAYS_MIDDLEWARE,
LANGUAGE_CODE='en-us',
TIME_ZONE='UTC',
USE_I18N=True,
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Django<2.0
Django
djangorestframework
requests
requests-cache
Expand Down

0 comments on commit 0a335d7

Please sign in to comment.