diff --git a/sami/django/mysite2/db.sqlite3 b/sami/django/mysite2/db.sqlite3 index e69de29..95016af 100644 Binary files a/sami/django/mysite2/db.sqlite3 and b/sami/django/mysite2/db.sqlite3 differ diff --git a/sami/django/mysite2/mysite2/settings.py b/sami/django/mysite2/mysite2/settings.py index 9db30f1..a23a153 100644 --- a/sami/django/mysite2/mysite2/settings.py +++ b/sami/django/mysite2/mysite2/settings.py @@ -25,12 +25,13 @@ SECRET_KEY = 'sb1cbc!m_esjnb381eh8!+(1$zi-%$h@ewu#3=cog+ls)d%)3z' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True -ALLOWED_HOSTS = [] - +ALLOWED_HOSTS = ['2a0a-e5c0-10-bee-7994-d023-5c29-7091.has-a.name'] + # Application definition INSTALLED_APPS = [ + 'polls.apps.PollsConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', @@ -105,7 +106,7 @@ AUTH_PASSWORD_VALIDATORS = [ LANGUAGE_CODE = 'en-us' -TIME_ZONE = 'UTC' +TIME_ZONE = 'Europe/Zurich' USE_I18N = True diff --git a/sami/django/mysite2/mysite2/urls.py b/sami/django/mysite2/mysite2/urls.py index 7ab8fd1..e7a42d7 100644 --- a/sami/django/mysite2/mysite2/urls.py +++ b/sami/django/mysite2/mysite2/urls.py @@ -1,3 +1,4 @@ + """mysite2 URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: @@ -14,8 +15,9 @@ Including another URLconf 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('polls/', include('polls.urls')), path('admin/', admin.site.urls), ] diff --git a/sami/django/mysite2/polls/.#models.py b/sami/django/mysite2/polls/.#models.py new file mode 120000 index 0000000..3884ade --- /dev/null +++ b/sami/django/mysite2/polls/.#models.py @@ -0,0 +1 @@ +sami@afro-linux-lenovo-b50-30.8898:1594292241 \ No newline at end of file diff --git a/sami/django/mysite2/polls/migrations/0001_initial.py b/sami/django/mysite2/polls/migrations/0001_initial.py new file mode 100644 index 0000000..3826812 --- /dev/null +++ b/sami/django/mysite2/polls/migrations/0001_initial.py @@ -0,0 +1,32 @@ +# Generated by Django 2.2.12 on 2020-07-10 14:30 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Question', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('question_text', models.CharField(max_length=200)), + ('pub_date', models.DateTimeField(verbose_name='date published')), + ], + ), + migrations.CreateModel( + name='Choice', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('choice_text', models.CharField(max_length=200)), + ('votes', models.IntegerField(default=0)), + ('question', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='polls.Question')), + ], + ), + ] diff --git a/sami/django/mysite2/polls/models.py b/sami/django/mysite2/polls/models.py index 71a8362..1914ee2 100644 --- a/sami/django/mysite2/polls/models.py +++ b/sami/django/mysite2/polls/models.py @@ -1,3 +1,27 @@ +from django.utils import timezone from django.db import models +import datetime + # Create your models here. + + +class Question(models.Model): + question_text = models.CharField(max_length=200) + pub_date = models.DateTimeField('date published') + + def __str__(self): + return self.question_text + + def was_published_recently(self): + return self.pub_date >= timezone.now() -datetime.timedelta(days=1) + +class Choice(models.Model): + question = models.ForeignKey(Question, on_delete=models.CASCADE) + choice_text = models.CharField(max_length=200) + votes = models.IntegerField(default=0) + + def __str__(self): + return self.choice_text + + diff --git a/sami/django/mysite2/polls/templates/polls/detail.html b/sami/django/mysite2/polls/templates/polls/detail.html new file mode 100644 index 0000000..6667640 --- /dev/null +++ b/sami/django/mysite2/polls/templates/polls/detail.html @@ -0,0 +1 @@ +{{ question }} diff --git a/sami/django/mysite2/polls/templates/polls/index.html b/sami/django/mysite2/polls/templates/polls/index.html new file mode 100644 index 0000000..71c2249 --- /dev/null +++ b/sami/django/mysite2/polls/templates/polls/index.html @@ -0,0 +1,22 @@ +{% if latest_question_list %} +
No polls are available.
+{% endif %} + +{{ error_message }}
{% endif %} + + diff --git a/sami/django/mysite2/polls/templates/polls/results.html b/sami/django/mysite2/polls/templates/polls/results.html new file mode 100644 index 0000000..3b2c74f --- /dev/null +++ b/sami/django/mysite2/polls/templates/polls/results.html @@ -0,0 +1,9 @@ +