Note This project is designed for training schools to develop simplified CRM
Introduction to CRM
CRM Full Name: Customer Relationship Management
Pain points without CRM
There are no drawbacks and pain points for CMR:
- Each sale uses Excel to count customer information, resulting in information not being synced and shared
- No record of customer information and follow-up information
- It's going to cause a single problem.
- Unable to count into single rate and report
- No record of communication with customer
- Customer Information table, unique client ID
- One-to-many follow-up records
- Customer status, registration and non-registration
- Customer Source Analysis
- Student Registration Information
- Students can report multiple courses, each of which has a score and a ranking
- Class information
Convert pain points into requirements
Class record for students
- Course Information
- Payment record
- User Usage Scenario Analysis
- Role management
- Rights Management
- Dynamic Menu
- On-line Job delivery
About table Structures
Follow-up complete post-supplement
About the Django Admin
Knowledge Point review:
Ways to use the admin in Django:
1. Create a good table class in models.py
2, the implementation of Python3 manager.py Makemigrations
3, the implementation of Python3 manager.py migrate
4. The default is to generate the Db.sqlite3 database file under the project file when the above operation is completed
5, in the admin.py file first import modes, and then register the table, the project code example is as follows:
from Import Admin # Register your models here. from Import Modelsadmin.site.register (models. Customer) Admin.site.register (models. Studyrecord) Admin.site.register (models. Role) Admin.site.register (models. Menu) Admin.site.register (models. Enrollment) Admin.site.register (models. classlist) Admin.site.register (models. Branch) Admin.site.register (models. Courserecord) Admin.site.register (models. Course) Admin.site.register (models. Followuprecord) Admin.site.register (models. UserProfile)
6, finally execute Python3 manage.py createsuperuser, create Admin user
How to invoke the Admin authentication feature in Django
If you want to invoke the admin authentication in Django you need:
When creating a class for a table in a models.py file, import a module first
From Django.contrib.auth.models import User
Then in the user information class, through and admin in the user table to establish a one-to-one relationship, so as to achieve the authentication function
class UserProfile (models. Model): ' user information '= models. Onetoonefield (User) = models. Charfield (MAX_LENGTH=32)
This allows the admin authentication in Django to be invoked
Using the admin authentication in the views.py function
The authentication function that invokes the admin in Django needs to import the following module, authenticate for authentication, login for login, logout for exiting
From Django.contrib.auth import authenticate,login,logout
The specific code is as follows:
defAcc_login (Request):ifRequest.method = ="POST": Username= Request. Post.get ("username") Password= Request. Post.get ("Password") User= Authenticate (username=username,password=password)#because this is called by the Django admin in the authentication function, so this time if the authentication successfully obtained is <class ' Django.contrib.auth.models.User ' > Object #If you want to get a specific user name, you can user.userprofile.name get #Print ("Res:", type (user), User.userprofile.name) ifUser:#AUTH Certification SuccessLogin (Request,user)returnredirect"/crm") returnRender (Request,"login.html")
What you need to know here is that authenticate returned is actually a user object
<class ' Django.contrib.auth.models.User ';
If you want to get a specific user name, you need to pass user.userprofile.name,
About Dynamic Menus
A different menu is displayed based on the user login that belongs to a different user role
(Here is a question to note, when a menu option belongs to more than one role, and this user belongs to multiple roles, this time will cause the user to log in when the menu option to repeat the problem)
Dynamic menu There's one more thing to do here, which is to give a background color when a menu is selected, i.e. dynamically add active
This can be set according to the URL, because each menu is a label and the href attribute of the A tag is the same as the URL of the current page.
By getting the current URL in JS is also ' {{Request.path}} '
About the self-customization features of the admin in Django
In the Django Admin you can customize the display of the field content, you need to do the following configuration in the admin.py configuration file:
class customeradmin (admin. Modeladmin): List_display = ( " id Span style= "COLOR: #800000" > ", " name ", " QQ , " Consultant ", " Consult_content ", " status " , " date ")
Create the class in admin.py, and let inherit admin.modeladmin
List_display represents the fields to be displayed, and the fields to be displayed are listed later so that you can see them on the front page
Of course, you can also use List_filter to implement filtered search functions.
Keyword search via search_fields
Some of the field editing functions are implemented through list_editable such as:
Write yourself an admin, named Kingadmin
Analysis Process:
First from the appearance analysis
When the Django Login admin appears, all the app names will be displayed, and all of the app's table names will be displayed under each app.
Here are a few knowledge points to note:
about how to get all the apps
All registered apps will be in Installed_apps in the sttings configuration file.
Here's how to get the following:
from Django import conf for app in Conf.settings.INSTALLED_APPS: try : print (__import__ ( " %s.kingadmin " %app) except Importerror as E: print (" app has no model kingadmin ")
This is done by importing the Django Conf module and then Conf.settings.INSTALLED_APPS to get all the app information,
About the Registration form
Analysis of the Django Admin source code can be seen about registration here, is to create a AdminSite class, and instantiate
Top a Registery dictionary when initializing a function
Each registration will be added to this dictionary, so we can imitate this to write
Here are a few things to know:
Custom Label Simple_tag
To create a process:
Create a Templatetags Package
Create a py file in Templatetags
Import Template module: From Django Import template
Register = template. Library ()
@register. Simple_tag
If there is HTML in the returned content, you will need to
From django.utils.safestring import Mark_safe
In the string to be returned: Mark_safe (content)
Most of the previous page import: {%load kingadmin_tags%} here kingadmin_tags is a py file created in the Templatetags package
Cond........
About developing a CRM system for Python