Skip to content

Commit f171a94

Browse files
committed
django基础知识实现的xadmin后台注册,models编写,数据迁移。
0 parents  commit f171a94

File tree

835 files changed

+220575
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

835 files changed

+220575
-0
lines changed

.idea/VueDjangoFrameWorkShop.iml

Lines changed: 33 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

VueDjangoFrameWorkShop/__init__.py

Whitespace-only changes.

VueDjangoFrameWorkShop/settings.py

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
"""
2+
Django settings for VueDjangoFrameWorkShop project.
3+
4+
Generated by 'django-admin startproject' using Django 2.0.2.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/2.0/topics/settings/
8+
9+
For the full list of settings and their values, see
10+
https://docs.djangoproject.com/en/2.0/ref/settings/
11+
"""
12+
13+
import os
14+
import sys
15+
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
16+
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
17+
sys.path.insert(0,BASE_DIR)
18+
sys.path.insert(0,os.path.join(BASE_DIR, 'apps'))
19+
sys.path.insert(0,os.path.join(BASE_DIR, 'extra_apps'))
20+
21+
# Quick-start development settings - unsuitable for production
22+
# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/
23+
24+
# SECURITY WARNING: keep the secret key used in production secret!
25+
SECRET_KEY = 'y5yew=o5yey*9ydgt74-st11qkt$3n_i9r-c+aw$lt0%x3%a^)'
26+
27+
# SECURITY WARNING: don't run with debug turned on in production!
28+
DEBUG = True
29+
30+
ALLOWED_HOSTS = []
31+
32+
# 此处重载是为了使我们的UserProfile生效
33+
AUTH_USER_MODEL = "users.UserProfile"
34+
35+
# Application definition
36+
37+
INSTALLED_APPS = [
38+
'django.contrib.admin',
39+
'django.contrib.auth',
40+
'django.contrib.contenttypes',
41+
'django.contrib.sessions',
42+
'django.contrib.messages',
43+
'django.contrib.staticfiles',
44+
'users.apps.UsersConfig',
45+
'goods.apps.GoodsConfig',
46+
'trade.apps.TradeConfig',
47+
'user_operation.apps.UserOperationConfig',
48+
'xadmin',
49+
'crispy_forms',
50+
'DjangoUeditor',
51+
]
52+
53+
MIDDLEWARE = [
54+
'django.middleware.security.SecurityMiddleware',
55+
'django.contrib.sessions.middleware.SessionMiddleware',
56+
'django.middleware.common.CommonMiddleware',
57+
'django.middleware.csrf.CsrfViewMiddleware',
58+
'django.contrib.auth.middleware.AuthenticationMiddleware',
59+
'django.contrib.messages.middleware.MessageMiddleware',
60+
'django.middleware.clickjacking.XFrameOptionsMiddleware',
61+
]
62+
63+
ROOT_URLCONF = 'VueDjangoFrameWorkShop.urls'
64+
65+
TEMPLATES = [
66+
{
67+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
68+
'DIRS': [os.path.join(BASE_DIR, 'templates')]
69+
,
70+
'APP_DIRS': True,
71+
'OPTIONS': {
72+
'context_processors': [
73+
'django.template.context_processors.debug',
74+
'django.template.context_processors.request',
75+
'django.contrib.auth.context_processors.auth',
76+
'django.contrib.messages.context_processors.messages',
77+
],
78+
},
79+
},
80+
]
81+
82+
WSGI_APPLICATION = 'VueDjangoFrameWorkShop.wsgi.application'
83+
84+
85+
# Database
86+
# https://docs.djangoproject.com/en/2.0/ref/settings/#databases
87+
88+
DATABASES = {
89+
'default': {
90+
'ENGINE': 'django.db.backends.mysql',
91+
'NAME': 'vue_shop',
92+
'USER': 'root',
93+
'PASSWORD': 'tp158917',
94+
'HOST':'127.0.0.1',
95+
"OPTIONS": {"init_command": "SET default_storage_engine=INNODB;"}
96+
}
97+
}
98+
99+
100+
# Password validation
101+
# https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators
102+
103+
AUTH_PASSWORD_VALIDATORS = [
104+
{
105+
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
106+
},
107+
{
108+
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
109+
},
110+
{
111+
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
112+
},
113+
{
114+
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
115+
},
116+
]
117+
118+
119+
# Internationalization
120+
# https://docs.djangoproject.com/en/2.0/topics/i18n/
121+
122+
# 语言改为中文
123+
LANGUAGE_CODE = 'zh-hans'
124+
125+
# 时区改为上海
126+
TIME_ZONE = 'Asia/Shanghai'
127+
128+
USE_I18N = True
129+
130+
USE_L10N = True
131+
132+
# 数据库存储使用时间,True时间会被存为UTC的时间
133+
USE_TZ = False
134+
135+
# Static files (CSS, JavaScript, Images)
136+
# https://docs.djangoproject.com/en/2.0/howto/static-files/
137+
138+
STATIC_URL = '/static/'
139+
140+
# 设置上传文件,图片访问路径
141+
MEDIA_URL = '/media/'
142+
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

VueDjangoFrameWorkShop/urls.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"""VueDjangoFrameWorkShop URL Configuration
2+
3+
The `urlpatterns` list routes URLs to views. For more information please see:
4+
https://docs.djangoproject.com/en/2.0/topics/http/urls/
5+
Examples:
6+
Function views
7+
1. Add an import: from my_app import views
8+
2. Add a URL to urlpatterns: path('', views.home, name='home')
9+
Class-based views
10+
1. Add an import: from other_app.views import Home
11+
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
12+
Including another URLconf
13+
1. Import the include() function: from django.urls import include, path
14+
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
15+
"""
16+
from django.views.static import serve
17+
18+
import xadmin
19+
from django.contrib import admin
20+
from django.urls import path, re_path, include
21+
22+
from VueDjangoFrameWorkShop.settings import MEDIA_ROOT
23+
24+
urlpatterns = [
25+
path('admin/', admin.site.urls),
26+
path('xadmin/', xadmin.site.urls),
27+
# 处理图片显示的url,使用Django自带serve,传入参数告诉它去哪个路径找,我们有配置好的路径MEDIAROOT
28+
re_path('media/(?P<path>.*)', serve, {"document_root": MEDIA_ROOT }),
29+
# 富文本相关url
30+
path('ueditor/', include('DjangoUeditor.urls')),
31+
]

VueDjangoFrameWorkShop/wsgi.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
WSGI config for VueDjangoFrameWorkShop project.
3+
4+
It exposes the WSGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.wsgi import get_wsgi_application
13+
14+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "VueDjangoFrameWorkShop.settings")
15+
16+
application = get_wsgi_application()

apps/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# encoding: utf-8
2+
__author__ = 'mtianyan'
3+
__date__ = '2018/2/11 0011 05:45'

apps/goods/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)