diff --git a/Django5/settings.py b/Django5/settings.py index 1fdd931..df25714 100644 --- a/Django5/settings.py +++ b/Django5/settings.py @@ -15,7 +15,6 @@ 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/5.2/howto/deployment/checklist/ @@ -27,7 +26,6 @@ DEBUG = True ALLOWED_HOSTS = [] - # Application definition INSTALLED_APPS = [ @@ -37,6 +35,7 @@ INSTALLED_APPS = [ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + "helloWorld.apps.HelloworldConfig" ] MIDDLEWARE = [ @@ -69,7 +68,6 @@ TEMPLATES = [ WSGI_APPLICATION = 'Django5.wsgi.application' - # Database # https://docs.djangoproject.com/en/5.2/ref/settings/#databases @@ -80,7 +78,6 @@ DATABASES = { } } - # Password validation # https://docs.djangoproject.com/en/5.2/ref/settings/#auth-password-validators @@ -99,7 +96,6 @@ AUTH_PASSWORD_VALIDATORS = [ }, ] - # Internationalization # https://docs.djangoproject.com/en/5.2/topics/i18n/ @@ -111,12 +107,14 @@ USE_I18N = True USE_TZ = True - # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/5.2/howto/static-files/ STATIC_URL = 'static/' +# 设置静态资源文件集合 +# STATICFILES_DIRS = [BASE_DIR / 'static', BASE_DIR / 'helloworld/images'] + # Default primary key field type # https://docs.djangoproject.com/en/5.2/ref/settings/#default-auto-field diff --git a/Django5/urls.py b/Django5/urls.py index b76b1a9..bd36cd4 100644 --- a/Django5/urls.py +++ b/Django5/urls.py @@ -17,6 +17,9 @@ Including another URLconf from django.contrib import admin from django.urls import path +import helloWorld.views + urlpatterns = [ path('admin/', admin.site.urls), + path('index/', helloWorld.views.index), ] diff --git a/helloWorld/__init__.py b/helloWorld/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/helloWorld/admin.py b/helloWorld/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/helloWorld/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/helloWorld/apps.py b/helloWorld/apps.py new file mode 100644 index 0000000..e3208d5 --- /dev/null +++ b/helloWorld/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class HelloworldConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'helloWorld' diff --git a/helloWorld/migrations/__init__.py b/helloWorld/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/helloWorld/models.py b/helloWorld/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/helloWorld/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/helloWorld/static/logo.jpg b/helloWorld/static/logo.jpg new file mode 100644 index 0000000..9d3171b Binary files /dev/null and b/helloWorld/static/logo.jpg differ diff --git a/helloWorld/tests.py b/helloWorld/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/helloWorld/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/helloWorld/views.py b/helloWorld/views.py new file mode 100644 index 0000000..2071caa --- /dev/null +++ b/helloWorld/views.py @@ -0,0 +1,6 @@ +from django.shortcuts import render + + +# Create your views here. +def index(request): + return render(request, 'index.html') diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..ba9bf19 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,11 @@ + + +
+ +Django5大爷你好!
+Python学习路线图 + + \ No newline at end of file