Python CRM项目一
开发环境:
- 语言Python3.X以上
- MTV WEB框架 Django
- 前端框架 jQuery+bootstrap
- 数据库 MySQL
运行环境
- 安装Python3.x
- 安装Django
- 除IE8以上的浏览器
项目需求:重写Django Admin的功能,实现对表动态的增删改查,实现权限的动态分配,实现自定义Action,等一系列组件扩展功能
项目功能图:

项目表UML表关系图

models.py表关系创建
from django.db import models
from django.contrib.auth.models import User
# Create your models here.
class Customer(models.Model):
'''客户信息表'''
name = models.CharField(max_length=32,null=True,blank=True)
qq = models.CharField(max_length=64,unique=True)
qq_name = models.CharField(max_length=64,null=True,blank=True)
phone = models.CharField(max_length=64,null=True,blank=True)
source_choices = ((0,'转介绍'),(1,'QQ群'),(2,'官网'),(3,'百度推广'),(4,'51cto'),(5,'知乎推荐'),(6,'市场推广'))
source = models.SmallIntegerField(choices=source_choices)
referral_from = models.CharField(verbose_name='转介绍人QQ',max_length=64,null=True,blank=True)
consult_course = models.ForeignKey('Course',verbose_name='咨询课程')
content = models.TextField(verbose_name='咨询详情')
consultant = models.ForeignKey('UserProfile',verbose_name='销售')
tags = models.ManyToManyField('Tag',blank=True,null=True);
memo = models.TextField(blank=True,null=True)
status_choice = (('signed','已报名'),('unregistered','未报名'))
status = models.CharField(max_length=64,choices=status_choice,default='unregistered',verbose_name='客户状态')
date = models.DateTimeField(auto_now_add=True) class Meta:
verbose_name_plural = '客户' def __str__(self):
return self.name class CustomerFollowUp(models.Model):
'''客户跟进表'''
customer = models.ForeignKey('Customer')
content = models.TextField(verbose_name='跟进内容')
consultant = models.ForeignKey('UserProfile')
intention_choices = ((0,'2周内报名'),(1,'1个月报名'),(2,'近期无报名计划'),(3,'已在其他机构报名'),(4,'已报名'),(5,'已拉黑'))
intention = models.SmallIntegerField(choices=intention_choices)
date = models.DateTimeField(auto_now_add=True) def __str__(self):
return '%s %s' % (self.customer.qq, self.intention) class Meta:
verbose_name_plural = '客户跟进记录' class Course(models.Model):
'''课程表'''
name = models.CharField(max_length=128,unique=True)
price = models.PositiveSmallIntegerField()
period = models.PositiveSmallIntegerField(verbose_name='周期(月)')
outline = models.TextField() def __str__(self):
return self.name class Meta:
verbose_name_plural = '课程' class Branch(models.Model):
'''校区表'''
name = models.CharField(max_length=128,unique=True)
addr = models.CharField(max_length=512) def __str__(self):
return self.name class Meta:
verbose_name_plural = '校区' class ClassList(models.Model):
'''班级表'''
branch = models.ForeignKey('Branch',verbose_name='分校')
course = models.ForeignKey('Course')
semester = models.PositiveSmallIntegerField(verbose_name='学期')
teachers = models.ManyToManyField('UserProfile')
class_type_choice = ((0,'面授班(脱产)'),(1,'面授班(周末)'),(2,'网络班'))
class_type = models.SmallIntegerField(choices=class_type_choice)
start_date = models.DateField(verbose_name='开班日期')
end_date = models.DateField(verbose_name='结业日期',blank=True,null=True) def __str__(self):
return '%s %s %s' % (self.branch, self.course, self.semester) class Meta:
unique_together = ('branch', 'course', 'semester')
verbose_name_plural = '班级' class CourseRecord(models.Model):
'''上课记录表'''
from_class = models.ForeignKey('ClassList',verbose_name='班级')
day_num = models.PositiveSmallIntegerField(verbose_name='第几节(天)')
teacher = models.ForeignKey('UserProfile')
has_homework = models.BooleanField(default=True)
homework_title = models.CharField(max_length=256,blank=True,null=True)
homework_content = models.TextField(blank=True,null=True)
outline = models.TextField(verbose_name='本节课大纲')
date = models.DateTimeField(auto_now_add=True) def __str__(self):
return '%s %s' % (self.from_class, self.day_num) class Meta:
unique_together = ('from_class', 'day_num')
verbose_name_plural = '上课记录' class StudyRecord(models.Model):
'''学习记录表'''
student = models.ForeignKey('Enrollment')
course_record = models.ForeignKey('CourseRecord')
attendance_choice = ((0,'已签到'),(1,'迟到'),(2,'缺勤'),(3,'早退'))
attendance = models.SmallIntegerField(choices=attendance_choice,default=0)
score_choices = ((100,'A+'),(90,'A'),(85,'B+'),(80,'B'),(75,'B-'),(70,'C+'),(60,'C'),(40,'C-'),(-50,'D'),(-100,'COPY'),(0,'N/A'))
score = models.SmallIntegerField(choices=score_choices)
memo = models.TextField(blank=True,null=True)
date = models.DateTimeField(auto_now_add=True) def __str__(self):
return '%s %s %s' % (self.student, self.course_record, self.score) class Meta:
unique_together = ('student', 'course_record')
verbose_name_plural = '学习记录' class Enrollment(models.Model):
'''学生报名表(学生报名信息,合同,入学日期,所报班级)'''
customer = models.ForeignKey('Customer')
enrolled_class = models.ForeignKey('ClassList',verbose_name='所报班级')
consultant = models.ForeignKey('UserProfile',verbose_name='课程顾问')
contact_agreed = models.BooleanField(default=False,verbose_name='学生已同意合同条款')
contact_approved = models.BooleanField(default=False,verbose_name='合同已审核')
date = models.DateTimeField(auto_now_add=True) def __str__(self):
return '%s %s' % (self.customer, self.enrolled_class) class Meta:
unique_together = ('customer', 'enrolled_class')
verbose_name_plural = '报名' class Payment(models.Model):
'''缴费记录'''
customer = models.ForeignKey('Customer')
course = models.ForeignKey('Course')
amount = models.PositiveIntegerField(verbose_name='数额',default=500)
consultant = models.ForeignKey('UserProfile')
date = models.DateTimeField(auto_now_add=True) def __str__(self):
return '%s %s' % (self.customer, self.amount) class Meta:
verbose_name_plural = '缴费记录' class UserProfile(models.Model):
'''账号表'''
user = models.OneToOneField(User)
name = models.CharField(max_length=32)
roles = models.ManyToManyField('Role',blank=True,null=True) def __str__(self):
return self.name class Role(models.Model):
'''角色表'''
name = models.CharField(max_length=64,unique=True) def __str__(self):
return self.name class Meta:
verbose_name_plural = '角色' class Tag(models.Model):
'''标签备注'''
name = models.CharField(max_length=64,unique=True) def __str__(self):
return self.name
class Meta:
verbose_name_plural = '标签'
在Settings文件中配置静态文件路径
STATIC_URL = '/static/'
STATICFILES_DIRS =(
os.path.join(BASE_DIR,'static'),
)
更改默认的数据库
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'prefect_crm',
'USER': 'root',
'PASSWORD': 'oldboy',
'HOST': '127.0.0.1',
'PORT': ''
}
}
在app下的__init__.py中插入
import pymysql
pymysql.install_as_MySQLdb()
Python CRM项目一的更多相关文章
- Python CRM项目二
一.准备工作 如果没有配置基本的项目,请参考 http://www.cnblogs.com/luhuajun/p/7771196.html 当我们配置完成后首先准备我们的app 创建2个app分别对应 ...
- Python CRM项目八
自定义用户认证 目的:实现Django自定义的认证系统,在生产环境都是根据此代码进行定制的 步骤: 1.在settings文件中配置要使用的类 #命名规则 app名称.类名 AUTH_USER_MOD ...
- Python CRM项目三
1.分页: 分页使用Django内置的分页模块来实现 官方的分页案例 from django.core.paginator import Paginator, EmptyPage, PageNotAn ...
- Python CRM项目七
仿照Django Admin实现对readonly的字段进行设置 功能点: 1.页面不可进行更改 2.如果改变html代码中的值,则需要进行后端的数据库数据校验 3.可以对某些字段进行自定制校验规则 ...
- Python CRM项目六
自定义Django Admin的action 在Django Admin中,可以通过action来自定义一些操作,其中默认的action的功能是选中多条数据来进行删除操作 我们在king_admin中 ...
- Python CRM项目四
实现Django Admin的多对多的复选框效果 效果:左边显示的是未选中的字段,右边显示的是已选中的字段,两边点击的标签可以互相更换 首先在king_admin.py中增加filter_horizo ...
- CRM项目总结
CRM项目总结 一:开发背景 在公司日益扩大的过程中,不可避免的会伴随着更多问题出现. 对外 : 如何更好的管理客户与公司的关系?如何更及时的了解客户日益发展的需求变 ...
- CRM项目之RBAC权限组件-day26
写在前面 上课第26天,打卡: 世间安得双全法 不负如来不负卿 s17day26 CRM项目 项目概要:XX公司CRM - 权限管理,公共组件,app ***** - 熟悉增删改查,Low *** - ...
- crm项目整理
crm项目整理 一.开发背景 由于公司人员的增多,原来通过excel表格存取方式过于繁琐,而且对于公司人员的调配和绩效考核等不能做到精确处理,所以开发crm系统,开始开发只是针对销售人员和客户,后 ...
随机推荐
- Java实现基本排序算法
稳定排序算法性能比较 冒泡排序代码: /** * 冒泡排序 * * @param arr * @return */ public int[] bubbleSort(int[] arr) { int t ...
- python import xxx 与 from xxx import xx 模块引入的区别
有如下脚本script1.py: A='aaaa'B='bbbb'C='cccc'print A,B,C 1.命令行交互模式下使用import 导入方式1: >>>import sc ...
- Spring配置中<context:annotation-config> VS <context:component-scan>
Spring 中在使用注解(Annotation)会涉及到< context:annotation-config> 和 < context:component-scan>配置, ...
- Day3 Python基础学习——文件操作、函数
一.文件操作 1.对文件操作流程 打开文件,得到文件句柄并赋值给一个变量 通过文件句柄对文件进行操作 关闭文件 #打开文件,读写文件,关闭文件 http://www.cnblogs.com/linha ...
- 简单又炫酷的two.js 二维动画教程
前 言 S N 今天呢给大家介绍一个小js框架,Two.JS.其实在自己学习的过程中并没有找到合适的教程,所以我这种学习延迟的同学是有一定难度的,然后准备给大家整理一份,简单易懂的小教程 ...
- 在CentOS6上编译安装实现LAMP(php-modules)+phpMyAdmin安装过程全记录
php与apache协作有三种模式:CGI.modules.FastCGI. 在CGI模式下,用户请求php文件时,apache会启动响应进程,调用php处理器处理请求,然后将结果返回给客户端.用户响 ...
- Ubuntu访问window下的磁盘分区出现“Error mounting /dev/sda5 at/media”错误的解决方法
我装ubuntu之前,电脑上安装了windows 10,为了装ubuntu,在window 10下的磁盘工具分配了30G的磁盘空间.安装完Ubuntu之后,访问window 10的磁盘分区出现“Err ...
- # C语言程序设计预备作业
一.针对老师和学生是怎样的关系的看法 ==首先我认同邹欣老师的看法,下面也是我自己的一点见解.== #### (1)师生在教育内容的教学上结成授受关系 .从教师与学生的社会角色规定意义上看,在知识上, ...
- Oracle的常用命令之备份和恢复数据库
1 将数据库TES完全导出,用户名system 密码manager 导出到D:\daochu.dmp中 exp system/manager@TEST file=d:\daochu.dmp 2 将数据 ...
- 有趣的flash例子
仓鼠 <object type="application/x-shockwave-flash" data="http://cdn.abowman.com/widge ...