修改原templates路径,删除,将setting.py中的路径置空
注册app
python manage.py startapp [app名称]
在app目录下创建static和templates目录
将项目中的资源文化进行拷贝
安装数据库
pip install mysqlclient-1.4.6-cp37-cp37m-win_amd64.whl
复制models层代码
- from django.db import models
-
- # Create your models here.
- class Case2(models.Model):
- case_id = models.CharField(max_length=255,primary_key=True)
- case_name = models.TextField(blank=True, null=True)
- case_introduction = models.TextField(blank=True, null=True)
- case_alias = models.TextField(blank=True, null=True)
- case_medical_insurance = models.CharField(max_length=255, blank=True, null=True)
- case_infectivity = models.CharField(max_length=255, blank=True, null=True)
- case_fre_occ_population = models.TextField(blank=True, null=True)
- case_related_symptoms = models.TextField(blank=True, null=True)
- case_dep_main = models.CharField(max_length=255, blank=True, null=True)
- case_dep_sub = models.CharField(max_length=255, blank=True, null=True)
- case_detail_symptoms = models.TextField(blank=True, null=True)
- case_therapeutic_method_short = models.TextField(blank=True, null=True)
- case_therapeutic_method_long = models.TextField(blank=True, null=True)
- case_information_link = models.TextField(blank=True, null=True)
- class Meta:
- managed = False
- db_table = 'case2'
数据库数据表设计:
Medical-case2:
复制views代码(核心算法设计)
settings代码改动部分
1、注册app
- INSTALLED_APPS = [
- 'django.contrib.admin',
- 'django.contrib.auth',
- 'django.contrib.contenttypes',
- 'django.contrib.sessions',
- 'django.contrib.messages',
- 'django.contrib.staticfiles',
- 'app.apps.AppConfig'
- ]
2、修改templates路径(第一步)
- 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',
- ],
- },
- },
- ]
3、数据库配置
- DATABASES = {
- 'default': {
- 'ENGINE': 'django.db.backends.mysql',
- 'NAME': 'medical',
- 'USER': 'root',
- 'PASSWORD': '123456',
- 'HOST': '127.0.0.1',
- 'PORT': '3306',
- }
- }
4、静态文件路径(如果静态文件名字没改则这里不用改)
STATIC_URL = '/static/'
复制urls代码
全部指令及所需安装库指令
①注册app
python manage.py startapp app
②安装数据库(手动)
pip install mysqlclient-1.4.6-cp37-cp37m-win_amd64.whl
③所需第三方库
pip install jieba
pip install fuzzywuzzy
pip install sklearn
pip install pandas
pip install tqdm
准备就绪,原神启动!