diff --git a/django_lostplaces/lostplaces/admin.py b/django_lostplaces/lostplaces/admin.py index 977bc23..c6f6280 100644 --- a/django_lostplaces/lostplaces/admin.py +++ b/django_lostplaces/lostplaces/admin.py @@ -6,6 +6,7 @@ from django.contrib import admin from django.contrib.auth import get_user_model from django.contrib.auth.admin import UserAdmin +from django.utils import timezone from lostplaces.models import * from lostplaces.forms import ExplorerCreationForm, ExplorerChangeForm diff --git a/django_lostplaces/lostplaces/tests/models/test_place_image_model.py b/django_lostplaces/lostplaces/tests/models/test_place_image_model.py index c1249a7..35f2277 100644 --- a/django_lostplaces/lostplaces/tests/models/test_place_image_model.py +++ b/django_lostplaces/lostplaces/tests/models/test_place_image_model.py @@ -8,6 +8,7 @@ from django.db import models from django.core.files import File from django.conf import settings from django.contrib.auth.models import User +from django.utils import timezone from lostplaces.models import PlaceImage, Place from lostplaces.tests.models import ModelTestCase @@ -26,7 +27,7 @@ class PlaceImageTestCase(ModelTestCase): place = Place.objects.create( name='Im a place', - submitted_when=datetime.datetime.now(), + submitted_when=timezone.now(), submitted_by=User.objects.get(username='testpeter').explorer, location='Testtown', latitude=50.5, @@ -55,7 +56,7 @@ class PlaceImageTestCase(ModelTestCase): description='Im a description', filename=os.path.join(settings.MEDIA_ROOT, 'im_a_image_copy.jpeg'), place=place, - submitted_when=datetime.datetime.now(), + submitted_when=timezone.now(), submitted_by=user.explorer ) diff --git a/django_lostplaces/lostplaces/tests/models/test_place_model.py b/django_lostplaces/lostplaces/tests/models/test_place_model.py index 04d9647..374fc68 100644 --- a/django_lostplaces/lostplaces/tests/models/test_place_model.py +++ b/django_lostplaces/lostplaces/tests/models/test_place_model.py @@ -4,6 +4,7 @@ from django.test import TestCase from django.db import models from django.contrib.auth.models import User +from django.utils import timezone from lostplaces.models import Place from lostplaces.tests.models import ModelTestCase @@ -22,7 +23,7 @@ class PlaceTestCase(ModelTestCase): place = Place.objects.create( name='Im a place', - submitted_when=datetime.datetime.now(), + submitted_when=timezone.now(), submitted_by=user.explorer, location='Testtown', latitude=50.5, diff --git a/django_lostplaces/lostplaces/tests/views/test_base_views.py b/django_lostplaces/lostplaces/tests/views/test_base_views.py index 94d4ce6..25ee0db 100644 --- a/django_lostplaces/lostplaces/tests/views/test_base_views.py +++ b/django_lostplaces/lostplaces/tests/views/test_base_views.py @@ -4,6 +4,7 @@ from django.test import TestCase, RequestFactory, Client from django.urls import reverse_lazy from django.contrib.auth.models import User, AnonymousUser from django.contrib.messages.storage.fallback import FallbackStorage +from django.utils import timezone from lostplaces.models import Place from lostplaces.views import IsAuthenticatedMixin @@ -54,7 +55,7 @@ class TestIsPlaceSubmitterMixin(TestCase): place = Place.objects.create( name='Im a place', - submitted_when=datetime.datetime.now(), + submitted_when=timezone.now(), submitted_by=user.explorer, location='Testtown', latitude=50.5, diff --git a/django_lostplaces/lostplaces/tests/views/test_place_views.py b/django_lostplaces/lostplaces/tests/views/test_place_views.py index 807d030..716422a 100644 --- a/django_lostplaces/lostplaces/tests/views/test_place_views.py +++ b/django_lostplaces/lostplaces/tests/views/test_place_views.py @@ -3,6 +3,8 @@ import datetime from django.test import TestCase, Client from django.urls import reverse from django.contrib.auth.models import User +from django.utils import timezone + from lostplaces.models import Place from lostplaces.views import ( @@ -30,7 +32,7 @@ class TestPlaceCreateView(ViewTestCase): place = Place.objects.create( name='Im a place', - submitted_when=datetime.datetime.now(), + submitted_when=timezone.now(), submitted_by=user.explorer, location='Testtown', latitude=50.5, @@ -63,7 +65,7 @@ class TestPlaceListView(ViewTestCase): place = Place.objects.create( name='Im a place', - submitted_when=datetime.datetime.now(), + submitted_when=timezone.now(), submitted_by=user.explorer, location='Testtown', latitude=50.5, @@ -95,7 +97,7 @@ class PlaceDetailViewTestCase(TaggableViewTestCaseMixin, MapableViewTestCaseMixi place = Place.objects.create( name='Im a place', - submitted_when=datetime.datetime.now(), + submitted_when=timezone.now(), submitted_by=user.explorer, location='Testtown', latitude=50.5,