diff --git a/sensibdiary/settings.py b/sensibdiary/settings.py index 2306fef..38a5d79 100644 --- a/sensibdiary/settings.py +++ b/sensibdiary/settings.py @@ -25,7 +25,7 @@ # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True -ALLOWED_HOSTS = [] +ALLOWED_HOSTS = ['localhost', '127.0.0.1', '.pythonanywhere.com'] # Application definition @@ -109,7 +109,7 @@ LANGUAGE_CODE = 'en-us' -TIME_ZONE = 'UTC' +TIME_ZONE = 'GB' USE_I18N = True diff --git a/sensibdiary/urls.py b/sensibdiary/urls.py index ea84670..82e1e86 100644 --- a/sensibdiary/urls.py +++ b/sensibdiary/urls.py @@ -14,8 +14,9 @@ 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin -from django.urls import path +from django.urls import include, path urlpatterns = [ path('admin/', admin.site.urls), + path('sleep-diary/', include('sleep.urls')), ] diff --git a/sleep/models.py b/sleep/models.py index 9cc81f6..9d17919 100644 --- a/sleep/models.py +++ b/sleep/models.py @@ -71,7 +71,7 @@ def __str__(self): class SleepInterruption(models.Model): - sleep_date = models.ForeignKey(Sleep, on_delete=models.CASCADE) + sleep_date = models.ForeignKey(Sleep, on_delete=models.CASCADE, related_name='interruptions') interruption_time = models.TimeField('time woke during sleep') diff --git a/sleep/static/templates/css/sleep.css b/sleep/static/templates/css/sleep.css index f88cba6..1f1f5a8 100644 --- a/sleep/static/templates/css/sleep.css +++ b/sleep/static/templates/css/sleep.css @@ -1,13 +1,15 @@ -.page-header { - background-color: teal; +.base-header { + margin-top: 0; padding: 20px 20px 20px 40px; + background-color: teal; } .page-header h1, .page-header h1 a, .page-header h1 a:visited, .page-header h1 a:active { color: #ffffff; font-size: 36pt; text-decoration: none; + } .content { diff --git a/sleep/static/templates/sleep/base.html b/sleep/templates/sleep/base.html similarity index 79% rename from sleep/static/templates/sleep/base.html rename to sleep/templates/sleep/base.html index 36e7a30..3f26093 100644 --- a/sleep/static/templates/sleep/base.html +++ b/sleep/templates/sleep/base.html @@ -6,11 +6,11 @@ - +
-{{ error_message }}
{% endif %} +Sleep date: {{ sleep.sleep_date|date:'d-m-Y'}}
+Time started preparing for bed: {{ sleep.time_start_preparing_for_sleep|date:'H:i e'}} |
Time went to bed: {{ sleep.time_went_into_bed|date:'H:i e' }} |
Time went to sleep: {{ sleep.time_went_to_sleep|date:'H:i e'}} |
Time woke in the morning: {{ sleep.time_woke_in_morning|date:'H:i e'}} |
Sleep date: {{ sleep.sleep_date|date:'d-m-Y'}}
+ + + {% endfor %} + + {% endblock %} diff --git a/sleep/urls.py b/sleep/urls.py new file mode 100644 index 0000000..06d6fc1 --- /dev/null +++ b/sleep/urls.py @@ -0,0 +1,9 @@ +from django.urls import path + +from . import views + +app_name = 'sleep' +urlpatterns = [ + path('', views.IndexView.as_view(), name='index'), + path('