diff --git a/README.MD b/README.MD index 6611524..75cf2a6 100644 --- a/README.MD +++ b/README.MD @@ -1,8 +1,8 @@ ### 项目简介: -new project with django_vue - +new project with fastapi +https://fastapi.tiangolo.com/zh/tutorial/bigger-applications/ 采用异步方式实现,考虑并发性能 @@ -15,13 +15,3 @@ new project with django_vue 3. 后端采用redis,mysql -django-admin startproject mysite - -python manage.py startapp polls -python manage.py migrate -python manage.py makemigrations polls -python manage.py sqlmigrate polls 0001 - -python manage.py createsuperuser -admin:kingsome -pengtao:tt123456 \ No newline at end of file diff --git a/manage.py b/manage.py deleted file mode 100755 index 1c3601e..0000000 --- a/manage.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python -"""Django's command-line utility for administrative tasks.""" -import os -import sys - - -def main(): - """Run administrative tasks.""" - os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myops.settings') - try: - from django.core.management import execute_from_command_line - except ImportError as exc: - raise ImportError( - "Couldn't import Django. Are you sure it's installed and " - "available on your PYTHONPATH environment variable? Did you " - "forget to activate a virtual environment?" - ) from exc - execute_from_command_line(sys.argv) - - -if __name__ == '__main__': - main() diff --git a/myops/__init__.py b/myops/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/myops/asgi.py b/myops/asgi.py deleted file mode 100644 index f8825f3..0000000 --- a/myops/asgi.py +++ /dev/null @@ -1,16 +0,0 @@ -""" -ASGI config for myops project. - -It exposes the ASGI callable as a module-level variable named ``application``. - -For more information on this file, see -https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/ -""" - -import os - -from django.core.asgi import get_asgi_application - -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myops.settings') - -application = get_asgi_application() diff --git a/myops/settings.py b/myops/settings.py deleted file mode 100644 index 819744b..0000000 --- a/myops/settings.py +++ /dev/null @@ -1,83 +0,0 @@ -""" -Django settings for myops project. - -Generated by 'django-admin startproject' using Django 3.2.4. - -For more information on this file, see -https://docs.djangoproject.com/en/3.2/topics/settings/ - -For the full list of settings and their values, see -https://docs.djangoproject.com/en/3.2/ref/settings/ -""" - -from pathlib import Path - -# Build paths inside the project like this: BASE_DIR / 'subdir'. -BASE_DIR = Path(__file__).resolve().parent.parent - -# Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/ - -# SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'django-insecure-&o5m%&g_psuco6225bp=xoid$iy0xdj%sgh^8x_%$y!ct=w=%j' - -# 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 = 'myops.urls' - -TEMPLATES = [ - {'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [BASE_DIR / 'templates'], '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 = 'myops.wsgi.application' - -# Database -# https://docs.djangoproject.com/en/3.2/ref/settings/#databases - -DATABASES = {'default': {'ENGINE': 'django.db.backends.sqlite3', 'NAME': BASE_DIR / 'db.sqlite3', }} - -# Password validation -# https://docs.djangoproject.com/en/3.2/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/3.2/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/3.2/howto/static-files/ - -STATIC_URL = '/static/' - -# Default primary key field type -# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field - -DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' diff --git a/myops/urls.py b/myops/urls.py deleted file mode 100644 index 694cc20..0000000 --- a/myops/urls.py +++ /dev/null @@ -1,19 +0,0 @@ -"""myops URL Configuration - -The `urlpatterns` list routes URLs to views. For more information please see: - https://docs.djangoproject.com/en/3.2/topics/http/urls/ -Examples: -Function views - 1. Add an import: from my_app import views - 2. Add a URL to urlpatterns: path('', views.home, name='home') -Class-based views - 1. Add an import: from other_app.views import Home - 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') -Including another URLconf - 1. Import the include() function: from django.urls import include, path - 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) -""" -from django.contrib import admin -from django.urls import path, include - -urlpatterns = [path('admin/', admin.site.urls), path('polls/', include('polls.urls'))] diff --git a/myops/wsgi.py b/myops/wsgi.py deleted file mode 100644 index bebdb36..0000000 --- a/myops/wsgi.py +++ /dev/null @@ -1,16 +0,0 @@ -""" -WSGI config for myops project. - -It exposes the WSGI callable as a module-level variable named ``application``. - -For more information on this file, see -https://docs.djangoproject.com/en/3.2/howto/deployment/wsgi/ -""" - -import os - -from django.core.wsgi import get_wsgi_application - -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myops.settings') - -application = get_wsgi_application() diff --git a/polls/__init__.py b/polls/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/polls/admin.py b/polls/admin.py deleted file mode 100644 index 684e8b6..0000000 --- a/polls/admin.py +++ /dev/null @@ -1,7 +0,0 @@ -from django.contrib import admin - -# Register your models here. -from django.contrib import admin -from .models import Question - -admin.site.register(Question) diff --git a/polls/apps.py b/polls/apps.py deleted file mode 100644 index 5a5f94c..0000000 --- a/polls/apps.py +++ /dev/null @@ -1,6 +0,0 @@ -from django.apps import AppConfig - - -class PollsConfig(AppConfig): - default_auto_field = 'django.db.models.BigAutoField' - name = 'polls' diff --git a/polls/migrations/__init__.py b/polls/migrations/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/polls/models.py b/polls/models.py deleted file mode 100644 index ec012fd..0000000 --- a/polls/models.py +++ /dev/null @@ -1,26 +0,0 @@ -from django.db import models - -# Create your models here. -from django.db import models -import datetime -from django.utils import timezone - - -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/polls/templates/polls/detail.html b/polls/templates/polls/detail.html deleted file mode 100644 index 35e519f..0000000 --- a/polls/templates/polls/detail.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - - Title - - -

- {{ question.question_text }} -

> - - - - \ No newline at end of file diff --git a/polls/templates/polls/index.html b/polls/templates/polls/index.html deleted file mode 100644 index 8578001..0000000 --- a/polls/templates/polls/index.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - - Title - - -{% if latest_question_list %} - -{% else %} -

No polls are available.

-{% endif %} - - \ No newline at end of file diff --git a/polls/tests.py b/polls/tests.py deleted file mode 100644 index 7ce503c..0000000 --- a/polls/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/polls/urls.py b/polls/urls.py deleted file mode 100644 index 5a54ced..0000000 --- a/polls/urls.py +++ /dev/null @@ -1,8 +0,0 @@ -# -*- coding: utf-8 -*- -from django.urls import path - -from . import views - -urlpatterns = [path('', views.index, name='index'), path('/', views.detail, name='detail'), - path('/results/', views.results, name='results'), - path('/vote/', views.vote, name='vote')] diff --git a/polls/views.py b/polls/views.py deleted file mode 100644 index 0f00cf7..0000000 --- a/polls/views.py +++ /dev/null @@ -1,41 +0,0 @@ -from django.shortcuts import render, get_object_or_404 - -# Create your views here. -from django.http import HttpResponse -from django.template import loader -from .models import Question -from django.http import Http404 - - -# def index(request): -# latest_question_list = Question.objects.order_by('-pub_date')[:5] -# template = loader.get_template('polls/index.html') -# context = {'latest_question_list': latest_question_list, } -# return HttpResponse(template.render(context, request)) - -def index(request): - 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) - # except Question.DoesNotExist: - # raise Http404('question does not exist') - question = get_object_or_404(Question, pk=question_id) - return render(request, 'polls/detail.html', {'question': question}) - - -# def detail(request, question_id): -# return HttpResponse("You 're looking at question %s." % question_id) - - -def results(request, question_id): - response = "you `re looking at the results of question %s." - return HttpResponse(response % question_id) - - -def vote(request, question_id): - return HttpResponse("you 're voting on question %s." % question_id)