From a2f3d3326e45ea554fc1e42351d43636ffe660f4 Mon Sep 17 00:00:00 2001 From: Yuri Date: Sun, 30 Apr 2017 00:22:04 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=B7=BB=E5=8A=A0README=202=E3=80=81?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0Install=E7=9B=AE=E5=BD=95=EF=BC=8C=E5=B9=B6?= =?UTF-8?q?=E9=85=8D=E5=A4=87requirements.txt=203=E3=80=81=E4=BF=AE?= =?UTF-8?q?=E6=94=B9urls.py=E9=85=8D=E7=BD=AE=EF=BC=8C=E5=85=BC=E5=AE=B9dj?= =?UTF-8?q?ango-1.10=E7=89=88=E6=9C=AC=204=E3=80=81Mysql=E9=A9=B1=E5=8A=A8?= =?UTF-8?q?=E5=99=A8=E4=BD=BF=E7=94=A8pymysql=E6=9B=BF=E4=BB=A3mysqldb?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- {SQL => Install/SQL}/mis.sql | 0 Install/requirements.txt | 4 ++++ README.md | 39 +++++++++++++++++++++++++++++++++++- basedata/admin.py | 2 +- basedata/urls.py | 2 +- invent/urls.py | 10 ++++----- mis/__init__.py | 5 +++++ mis/urls.py | 16 +++++++-------- selfhelp/urls.py | 2 +- 9 files changed, 62 insertions(+), 18 deletions(-) rename {SQL => Install/SQL}/mis.sql (100%) create mode 100644 Install/requirements.txt diff --git a/SQL/mis.sql b/Install/SQL/mis.sql similarity index 100% rename from SQL/mis.sql rename to Install/SQL/mis.sql diff --git a/Install/requirements.txt b/Install/requirements.txt new file mode 100644 index 0000000..e65a21a --- /dev/null +++ b/Install/requirements.txt @@ -0,0 +1,4 @@ +Django=1.10.6 +PyMySQL=0.7.9 +xlwt=1.0.0 +xlrd=1.2.0 \ No newline at end of file diff --git a/README.md b/README.md index 545d9c1..41538f7 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,16 @@ Django-ERP是一款基于Django开发的ERP管理软件,包含常用的销售 Forked from zhuinfo Django-ERP 感谢他的付出。 # 安装指南 + +> 我的开发、测试环境是Python2.7的,所以这个文档大多数情况我默认会使用这个条件,有个别测试不到位的可能还需要慢慢完善。 + 请先确保您已安装了Python 2.7,并已配置好了数据库,本文档会略过这部分内容(理论上Django是可以支持MYSql、PGSQL、SQLite、Oracle等主流数据库的,但是建议不要嘬,用自己熟悉的数据库,因为数据是无价的。) 验证方法请通过python --version查看版本,以及数据库 确认用户名和密码是否登录正常 +后续我争取不上requirements.txt,远期目标我个人是希望能做个dock镜像,并让它能慢慢顺着Python3和新版本的django平滑过渡上去。 + ## 数据库配置 + 数据库配置项在mis/settings.py文件中 在88-96行为Mysql数据库配置 @@ -26,4 +32,35 @@ DATABASES = { ## 克隆代码 > git clone https://github.com/bg4hkq/Django-ERP.git -> + + +## 导入数据库 +> mysql -uroot -proot mis < Install/mis.sql + +## 运行测试服务器 +> python manage.py runserver + +## 创建管理员账户(因为我没找到SQL库里admin的密码) +``` +C:\Django-ERP>python manage.py createsuperuser + +You have 3 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth. +Run 'python manage.py migrate' to apply them. +Username (leave blank to use 'baoz'): system +Email address: yurihuang@me.com +Password: +Password (again): +Superuser created successfully. + +C:\Django-ERP> +``` + +# 排错 + +## MYSQL驱动错误 +``` +django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb +``` + +出现No module named MySQLdb是django找不到MySQL驱动导致的问题,所以需要先安装一个数据库驱动。 + diff --git a/basedata/admin.py b/basedata/admin.py index a55761c..7a0cd81 100644 --- a/basedata/admin.py +++ b/basedata/admin.py @@ -4,7 +4,7 @@ from django.forms import models from django.forms import fields,TextInput,Textarea from django.contrib import messages from django.utils.translation import ugettext_lazy as _ -from django.contrib.contenttypes.generic import GenericTabularInline +from django.contrib.contenttypes.admin import GenericTabularInline from common import generic from basedata.models import ValueList,ValueListItem,Address,Partner,BankAccount,Project,Measure,Material,Brand,\ Category,Warehouse,TechnicalParameterName,TechnicalParameterValue,Trade,ExpenseAccount,Employee,Family,Education,\ diff --git a/basedata/urls.py b/basedata/urls.py index e9d2ec5..5a59f9f 100644 --- a/basedata/urls.py +++ b/basedata/urls.py @@ -2,5 +2,5 @@ from django.conf.urls import include, url,static import basedata.views urlpatterns = [ - url(r"dataimport/(?P\d+)/action", 'basedata.views.action_import'), + url(r"dataimport/(?P\d+)/action", basedata.views.action_import), ] diff --git a/invent/urls.py b/invent/urls.py index f5bbc89..b2e1020 100644 --- a/invent/urls.py +++ b/invent/urls.py @@ -2,9 +2,9 @@ from django.conf.urls import include, url,static import invent.views urlpatterns = [ - url(r"stockin/(?P\d+)/cin", 'invent.views.action_in'), - url(r"initialinventory/(?P\d+)/cin", 'invent.views.action_init'), - url(r"stockout/(?P\d+)/out", 'invent.views.action_out'), - url(r"warereturn/(?P\d+)/cin", 'invent.views.action_return'), - url(r"wareadjust/(?P\d+)/adjust", 'invent.views.action_adjust'), + url(r"stockin/(?P\d+)/cin", invent.views.action_in), + url(r"initialinventory/(?P\d+)/cin", invent.views.action_init), + url(r"stockout/(?P\d+)/out", invent.views.action_out), + url(r"warereturn/(?P\d+)/cin", invent.views.action_return), + url(r"wareadjust/(?P\d+)/adjust", invent.views.action_adjust), ] diff --git a/mis/__init__.py b/mis/__init__.py index fbb0a62..7b1a6e3 100644 --- a/mis/__init__.py +++ b/mis/__init__.py @@ -1,3 +1,8 @@ +#! /usr/bin/env python +# -*- coding: utf-8 -*- +import pymysql +pymysql.install_as_MySQLdb() +#解决mysql-python的历史遗留问题(Yuri_2017-04-29) from django.contrib import admin admin.site.site_header = 'Django-ERP' diff --git a/mis/urls.py b/mis/urls.py index 321801a..6250797 100644 --- a/mis/urls.py +++ b/mis/urls.py @@ -1,19 +1,17 @@ -from django.conf.urls import include, url,static +from django.conf.urls import include, url, static from django.contrib import admin from mis import settings -import workflow +import workflow.views import invent.urls import basedata.urls import selfhelp.urls -import mis +import mis.views urlpatterns = [ - # Examples: - url(r'^$', 'mis.views.home'), - # url(r'^blog/', include('blog.urls')), - url(r"^admin/(?P\w+)/(?P\w+)/(?P\d+)/start",'workflow.views.start'), - url(r"^admin/(?P\w+)/(?P\w+)/(?P\d+)/approve/(?P\d+)",'workflow.views.approve'), - url(r"^admin/(?P\w+)/(?P\w+)/(?P\d+)/restart/(?P\d+)",'workflow.views.restart'), + url(r'^$', mis.views.home), + url(r"^admin/(?P\w+)/(?P\w+)/(?P\d+)/start", workflow.views.start), + url(r"^admin/(?P\w+)/(?P\w+)/(?P\d+)/approve/(?P\d+)", workflow.views.approve), + url(r"^admin/(?P\w+)/(?P\w+)/(?P\d+)/restart/(?P\d+)", workflow.views.restart), url(r'^admin/', include(admin.site.urls)), url(r'^admin/invent/', include(invent.urls)), url(r'^admin/basedata/', include(basedata.urls)), diff --git a/selfhelp/urls.py b/selfhelp/urls.py index 750debd..dd0b214 100644 --- a/selfhelp/urls.py +++ b/selfhelp/urls.py @@ -2,5 +2,5 @@ from django.conf.urls import include, url,static import selfhelp.views urlpatterns = [ - url(r"(?P\w+)/(?P\d+)/pay", 'selfhelp.views.pay_action'), + url(r"(?P\w+)/(?P\d+)/pay", selfhelp.views.pay_action), ]