Code Monkey home page Code Monkey logo

chen-huai / django2_dailyfresh Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pad0y/django2_dailyfresh

0.0 1.0 0.0 4.91 MB

dailyfresh电商项目,替换django框架为2.X并重构,美化了下后台管理页面,该项目包含了实际开发中的电商项目中大部分的功能开发和知识点实践, 是一个非常不错的django学习项目,同时也记录在替换框架中遇到的坑,希望对各位的学习有所帮助。

License: MIT License

Python 37.54% HTML 46.11% CSS 10.70% JavaScript 3.56% Dockerfile 2.09%

django2_dailyfresh's Introduction

CSDN Build Status Finish

天天生鲜-django2.2版本

简介

本项目替换原项目框架django1.8为最新版的django2.2.5(已修复为2.2.10),该项目包含了实际开发中的电商项目中大部分的功能开发和知识点实践, 是一个非常不错的django学习项目,同时也记录在替换框架中遇到的坑,所遇到的django1.x和2.x的区别,希望对各位的学习有所帮助。

关键词:django2 celery fdfs haystack whoosh redis nginx 高并发 分布式

主要技术栈

celery:分别负责用户注册异步发送邮件以及不同用户登陆系统动态生成首页
fdfs+nginx:存储网站静态文件,实现项目和资源分离,达到分布式效果
haystack+whoosh+jieba:全文检索框架,修改底层haystack库使之对中文搜索更加友好
redis:作为django缓存和session存储后端,提升网站性能,给予用户更好体验

开发环境

python:3.6.5
django:2.2.10
pycharm:2019.2
OS: windows 10

功能模块

  • 用户模块
    • 注册
    • 登录
    • 激活(celery)
    • 退出
    • 个人中心
    • 地址管理
  • 商品模块
    • 首页(celery)
    • 商品详情
    • 商品列表
    • 搜索功能(haystack+whoosh)
  • 购物车模块(redis)
    • 增加
    • 删除
    • 修改
    • 查询
  • 订单模块
    • 确认订单页面
    • 订单创建
    • 请求支付(支付宝)
    • 查询支付结果
    • 评论

项目架构图

项目架构图

数据库表分析图

数据库表分析图

依赖环境和疑难解答

项目部署(开发环境)

  • 依赖库安装
pip install -U pip
pip install -r requirements.txt
  • mysql数据库创建
CREATE DATABASE `dailyfresh` CHARACTER SET 'utf8';
  • 启动项目所需服务(win10)
# windows redis的启动,配置文件在redis安装目录下
$ redis-server redis.windows.conf

# 启动celery, 进入项目虚拟环境,在项目根目录下执行
$ celery -A celery_tasks.tasks worker --loglevel=info -P eventlet

启动FastDFS服务, 启动nginx

fdfs的安装方式有两种:

FDFS的安装配置是一件比较麻烦的事情,因此提供FDFS的Dockerfile, 执行docker build -t docker/fdfs . 然后执行

docker run -d djang/fdfs \
    -p 8888:8888 \
    -p 22122:22122 \
    -e TZ=Asia/Shanghai \
    -v /data/fdfs:/var/local/fdfs \
    --restart=always

两种方法选择一种即可,建议docker搭建FDFS方便快捷! FDFS环境准备好之后执行如下命令(本地环境安装),docker方式启动无需执行此步骤。

$ /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf start
$ /usr/bin/fdfs_storaged /etc/fdfs/storage.conf start
$ nginx

项目配置文件修改

1. 重命名Django2_dailyfresh文件夹下的settings.py.example
   文件为settings.py

2. 修改数据库配置信息
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'dailyfresh',
        'HOST': 'localhost',
        'PORT': '3306',
        'USER': '#',  # 数据库用户名
        'PASSWORD': '#',  # 数据库密码
    }
}

3. 修改邮箱配置信息,163邮箱配置信息自查
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.qq.com'
EMAIL_PORT = 25
EMAIL_HOST_USER = '[email protected]'  # 发送邮件的邮箱
EMAIL_HOST_PASSWORD = 'xxxx'  # qq邮箱授权码
# EMAIL_USE_TLS = True  # 与SMTP服务器通信时,是否启动TLS链接(安全链接)
EMAIL_FROM = '天天生鲜<[email protected]>'  # EMAIL_FROM 和 EMAIL_HOST_USER必须一样

4. 填写fdfs的配置信息,注意端口是nginx的端口
FDFS_STORAGE_URL = 'http://ip:port/'  

5. 支付功能不需要用到的保持默认即可,需要用到移步官方文档或看配置文件注释

迁移数据库

python manage.py makemigrations
python manage.py migrate

启动

# 创建超级管理员
python manage.py createsuperuser
# 启动服务
python manage.py runserver

效果图

首页效果图 首页效果图 后台显示

BUGFIX

后言

如果本项目能帮助到在学习django2的你或者对你有其他帮助记得给个star噢!:wink: 若有什么需要改进或者疑问的地方欢迎提出issue

django2_dailyfresh's People

Contributors

pad0y avatar dependabot[bot] avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.