From a465052e909ed74144c4972ab2ee39a3f83dd9b0 Mon Sep 17 00:00:00 2001 From: doepy <8428487+doepy@user.noreply.gitee.com> Date: Sun, 28 Mar 2021 23:04:34 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=96=B0=E5=BB=BA=20=E7=AC=AC=E5=8D=81?= =?UTF-8?q?=E4=B8=89=E5=91=A8=5F=E7=AC=AC=E4=BA=8C=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../.keep" | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\272\214\350\212\202 /.keep" diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\272\214\350\212\202 /.keep" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\272\214\350\212\202 /.keep" new file mode 100644 index 00000000..e69de29b -- Gitee From d8457e3454509385dbde775fd382187162d3a88f Mon Sep 17 00:00:00 2001 From: doepy <8428487+doepy@user.noreply.gitee.com> Date: Sun, 28 Mar 2021 23:04:54 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=96=B0=E5=BB=BA=20=E7=AC=AC=E5=8D=81?= =?UTF-8?q?=E4=B8=89=E5=91=A8=5F=E7=AC=AC=E4=B8=89=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../.keep" | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\270\211\350\212\202 /.keep" diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\270\211\350\212\202 /.keep" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\270\211\350\212\202 /.keep" new file mode 100644 index 00000000..e69de29b -- Gitee From 68e12c4086092dbc2b8dec2ebc1a798fde72634b Mon Sep 17 00:00:00 2001 From: doepy <8428487+doepy@user.noreply.gitee.com> Date: Sun, 28 Mar 2021 23:08:03 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E7=AC=AC=E5=8D=81=E4=B8=89=E5=91=A8=5F?= =?UTF-8?q?=E7=AC=AC=E4=B8=89=E8=8A=82=20=E7=AC=AC=E5=8D=81=E4=B8=89?= =?UTF-8?q?=E5=91=A8=5F=E7=AC=AC=E4=B8=89=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin.py" | 8 ++ .../detail.html" | 12 ++ .../index.html" | 9 ++ .../results.html" | 9 ++ .../settings.py" | 126 ++++++++++++++++++ .../urls.py" | 14 ++ .../views.py" | 62 +++++++++ 7 files changed, 240 insertions(+) create mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\270\211\350\212\202 /admin.py" create mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\270\211\350\212\202 /detail.html" create mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\270\211\350\212\202 /index.html" create mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\270\211\350\212\202 /results.html" create mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\270\211\350\212\202 /settings.py" create mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\270\211\350\212\202 /urls.py" create mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\270\211\350\212\202 /views.py" diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\270\211\350\212\202 /admin.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\270\211\350\212\202 /admin.py" new file mode 100644 index 00000000..63a9bebb --- /dev/null +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\270\211\350\212\202 /admin.py" @@ -0,0 +1,8 @@ +from django.contrib import admin + +# Register your models here. + +from .models import Question, Choice + +admin.site.register(Question) +admin.site.register(Choice) \ No newline at end of file diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\270\211\350\212\202 /detail.html" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\270\211\350\212\202 /detail.html" new file mode 100644 index 00000000..38e66fd5 --- /dev/null +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\270\211\350\212\202 /detail.html" @@ -0,0 +1,12 @@ +

{{ question.question_text }}

+ +{% if error_message %}

{{ error_message }}

{% endif %} + +
+{% csrf_token %} +{% for choice in question.choice_set.all %} + +
+{% endfor %} + +
\ No newline at end of file diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\270\211\350\212\202 /index.html" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\270\211\350\212\202 /index.html" new file mode 100644 index 00000000..65478135 --- /dev/null +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\270\211\350\212\202 /index.html" @@ -0,0 +1,9 @@ +{% if latest_question_list %} + +{% else %} +

No polls are available.

+{% endif %} \ No newline at end of file diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\270\211\350\212\202 /results.html" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\270\211\350\212\202 /results.html" new file mode 100644 index 00000000..24c1e0c1 --- /dev/null +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\270\211\350\212\202 /results.html" @@ -0,0 +1,9 @@ +

{{ question.question_text }}

+ + + +Vote again? \ No newline at end of file diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\270\211\350\212\202 /settings.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\270\211\350\212\202 /settings.py" new file mode 100644 index 00000000..fad1b039 --- /dev/null +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\270\211\350\212\202 /settings.py" @@ -0,0 +1,126 @@ +""" +Django settings for mysite project. + +Generated by 'django-admin startproject' using Django 2.0. + +For more information on this file, see +https://docs.djangoproject.com/en/2.0/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/2.0/ref/settings/ +""" + +import os + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'epfv*#g3ppeyu6m41c23@cfzn45qi-k5&*r76rysp7!c!62uzo' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'polls.apps.PollsConfig', + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + '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', +] + +ROOT_URLCONF = 'mysite.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'mysite.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/2.0/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.mysql', + 'NAME': 'polls', + 'USER': 'root', + 'PASSWORD': 'lmc.123', + 'HOST': '127.0.0.1', + 'PORT': '3306' + + } +} + + +# Password validation +# https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/2.0/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/2.0/howto/static-files/ + +STATIC_URL = '/static/' diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\270\211\350\212\202 /urls.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\270\211\350\212\202 /urls.py" new file mode 100644 index 00000000..7e3d4824 --- /dev/null +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\270\211\350\212\202 /urls.py" @@ -0,0 +1,14 @@ +from django.urls import path +from . import views + +app_name = 'polls' +urlpatterns = [ + # ex: /polls/ + path('', views.IndexView.as_view(), name='index'), + # ex: /polls/5/ + path('/', views.detail, name='detail'), + # ex: /polls/5/results/ + path('/results/', views.results, name='results'), + # ex: /polls/5/vote/ + path('/vote/', views.vote, name='vote'), +] diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\270\211\350\212\202 /views.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\270\211\350\212\202 /views.py" new file mode 100644 index 00000000..282ba912 --- /dev/null +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\270\211\350\212\202 /views.py" @@ -0,0 +1,62 @@ +from django.shortcuts import render, get_object_or_404 +from django.http import HttpResponse, Http404, HttpResponseRedirect +from django.urls import reverse +from django.views import generic +from .models import Question, Choice +# Create your views here. + + +class IndexView(generic.TemplateView): + template_name = "polls/index.html" + + def get_context_data(self, **kwargs): + latest_question_list = Question.objects.order_by('-pub_date')[:5] + context = { + 'latest_question_list': latest_question_list, + } + return context + +def index(request): + """ + request 就是作为参数传递进来的请求对象 + :param request: + :return: + """ + latest_question_list = Question.objects.order_by('-pub_date')[:5] + context = { + 'latest_question_list': latest_question_list, + } + return render(request, 'polls/index.html', context) + + +def detail(request, question_id): + try: + question = Question.objects.get(pk=question_id) + context = { + "question": question + } + except Question.DoesNotExist: + raise Http404("Question does not exist") + return render(request, "polls/detail.html",) + +def results(request, question_id): + question = get_object_or_404(Question, pk=question_id) + return render(request, 'polls/results.html', {'question': question}) + +def vote(request, question_id): + question = get_object_or_404(Question, pk=question_id) + try: + selected_choice = question.choice_set.get(pk=request.POST['choice']) + except (KeyError, Choice.DoesNotExist): + # Redisplay the question voting form. + return render(request, 'polls/detail.html', { + 'question': question, + 'error_message': "You didn't select a choice.", + }) + else: + selected_choice.votes += 1 + selected_choice.save() + # Always return an HttpResponseRedirect after successfully dealing + # with POST data. This prevents data from being posted twice if a + # user hits the Back button. + return HttpResponseRedirect(reverse('polls:results', args=(question.id,))) \ No newline at end of file -- Gitee From 11374a8ca268a82c1942b03d7c902c14b2c5bf9f Mon Sep 17 00:00:00 2001 From: doepy <8428487+doepy@user.noreply.gitee.com> Date: Sun, 28 Mar 2021 23:08:37 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E7=AC=AC=E5=8D=81=E4=B8=89=E5=91=A8=5F?= =?UTF-8?q?=E7=AC=AC=E4=BA=8C=E8=8A=82=20=E7=AC=AC=E5=8D=81=E4=B8=89?= =?UTF-8?q?=E5=91=A8=5F=E7=AC=AC=E4=BA=8C=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../__init__.py" | 0 .../apps.py" | 5 +++++ .../models.py" | 14 ++++++++++++++ .../urls.py" | 14 ++++++++++++++ 4 files changed, 33 insertions(+) create mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\272\214\350\212\202 /__init__.py" create mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\272\214\350\212\202 /apps.py" create mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\272\214\350\212\202 /models.py" create mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\272\214\350\212\202 /urls.py" diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\272\214\350\212\202 /__init__.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\272\214\350\212\202 /__init__.py" new file mode 100644 index 00000000..e69de29b diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\272\214\350\212\202 /apps.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\272\214\350\212\202 /apps.py" new file mode 100644 index 00000000..c46d01b8 --- /dev/null +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\272\214\350\212\202 /apps.py" @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class PollsConfig(AppConfig): + name = 'polls' diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\272\214\350\212\202 /models.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\272\214\350\212\202 /models.py" new file mode 100644 index 00000000..0bd0fe17 --- /dev/null +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\272\214\350\212\202 /models.py" @@ -0,0 +1,14 @@ +from django.db import models + +# Create your models here. + + +class Question(models.Model): + question_text = models.CharField(max_length=200) + pub_date = models.DateTimeField('date published') + + +class Choice(models.Model): + question = models.ForeignKey(Question, on_delete=models.CASCADE) + choice_text = models.CharField(max_length=200) + votes = models.IntegerField(default=0) diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\272\214\350\212\202 /urls.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\272\214\350\212\202 /urls.py" new file mode 100644 index 00000000..c290a211 --- /dev/null +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/3\347\217\255/3\347\217\255_\351\231\266\345\206\266/3\347\217\255_\351\231\266\345\206\266_\347\254\254\345\215\201\344\270\211\345\221\250 /\347\254\254\345\215\201\344\270\211\345\221\250_\347\254\254\344\272\214\350\212\202 /urls.py" @@ -0,0 +1,14 @@ +from django.urls import path +from . import views + +app_name = 'polls' +urlpatterns = [ + # ex: /polls/ + path('', views.index, name='index'), + # ex: /polls/5/ + path('/', views.detail, name='detail'), + # ex: /polls/5/results/ + path('/results/', views.results, name='results'), + # ex: /polls/5/vote/ + path('/vote/', views.vote, name='vote'), +] -- Gitee