Skip to content

Commit

Permalink
Update syntax to Django 2
Browse files Browse the repository at this point in the history
  • Loading branch information
mimischi committed Dec 30, 2017
1 parent 7b1f6c1 commit c640db5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
6 changes: 2 additions & 4 deletions config/urls.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
# -*- coding: utf-8 -*-
"""URLs for geomat project"""


from django.conf import settings
from django.conf.urls import include, url
from django.conf.urls.static import static
from django.contrib import admin
from django.contrib.staticfiles.storage import staticfiles_storage
from django.views import defaults as default_views
from django.views.generic import RedirectView
from rest_framework.documentation import include_docs_urls

from geomat.stein.views import gallery_view
from rest_framework.documentation import include_docs_urls

urlpatterns = [
url(r'^$', gallery_view, name="home"),
# Redirect users from outdated 'preview/' to '/'
url(r'^preview/', RedirectView.as_view(pattern_name='home')),

# Django Admin, use {% url 'admin:index' %}
url(settings.ADMIN_URL, include(admin.site.urls)),
url(settings.ADMIN_URL, admin.site.urls),

# Documentation for the REST API
url(r'^api-docs/', include_docs_urls(title='GeoMat API documentation')),
Expand Down
2 changes: 1 addition & 1 deletion geomat/stein/migrations/0003_photograph.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Migration(migrations.Migration):
('online_status', models.BooleanField(default=False, verbose_name='active photograph?')),
('created_at', models.DateTimeField(auto_now_add=True, verbose_name='created at')),
('last_modified', models.DateTimeField(auto_now=True, verbose_name='last modified')),
('handpiece', models.ForeignKey(to='stein.Handpiece')),
('handpiece', models.ForeignKey(to='stein.Handpiece', on_delete=models.CASCADE)),
],
),
]
18 changes: 11 additions & 7 deletions geomat/stein/models.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from django.contrib.postgres.fields import ArrayField
from django.db import models
from django.utils.translation import ugettext_lazy as _
from stdimage.models import StdImageField

from geomat.stein.fields import ChoiceArrayField
from stdimage.models import StdImageField


# Mostly all fields are defined as CharFields, so the input is easier.
Expand Down Expand Up @@ -112,7 +111,8 @@ class MineralType(models.Model):
null=True,
blank=True,
verbose_name=_('classification'),
related_name="mineral_type")
related_name="mineral_type",
on_delete=models.CASCADE)

class Meta:
verbose_name = _("mineral type")
Expand Down Expand Up @@ -147,7 +147,8 @@ class Cleavage(models.Model):
blank=True,
null=True,
verbose_name=_("mineral type"),
related_name="cleavage")
related_name="cleavage",
on_delete=models.CASCADE)


class CrystalSystem(models.Model):
Expand All @@ -169,7 +170,8 @@ class CrystalSystem(models.Model):
MineralType,
null=True,
verbose_name=_('mineral type'),
related_name="crystallsystem")
related_name="crystallsystem",
on_delete=models.CASCADE)
crystal_system = models.CharField(
max_length=2,
blank=True,
Expand Down Expand Up @@ -249,7 +251,8 @@ class Photograph(models.Model):
'thumbnail': (100, 100, True),
},
db_index=True)
handpiece = models.ForeignKey(Handpiece, related_name="photograph")
handpiece = models.ForeignKey(
Handpiece, related_name="photograph", on_delete=models.CASCADE)
orientation = models.CharField(
max_length=1,
choices=ORIENTATION_CHOICES,
Expand Down Expand Up @@ -335,4 +338,5 @@ class QuizAnswer(models.Model):
QuizQuestion,
null=True,
verbose_name=_("question"),
related_name="answers")
related_name="answers",
on_delete=models.CASCADE)

0 comments on commit c640db5

Please sign in to comment.