Skip to content

Commit

Permalink
1、添加README
Browse files Browse the repository at this point in the history
2、添加Install目录,并配备requirements.txt
3、修改urls.py配置,兼容django-1.10版本
4、Mysql驱动器使用pymysql替代mysqldb
  • Loading branch information
bg4hkq committed Apr 29, 2017
1 parent c99727d commit a2f3d33
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 18 deletions.
File renamed without changes.
4 changes: 4 additions & 0 deletions Install/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Django=1.10.6
PyMySQL=0.7.9
xlwt=1.0.0
xlrd=1.2.0
39 changes: 38 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@ Django-ERP是一款基于Django开发的ERP管理软件,包含常用的销售
Forked from <a href="https://github.com/zhuinfo/Django-ERP">zhuinfo Django-ERP</a> 感谢他的付出。

# 安装指南

> 我的开发、测试环境是Python2.7的,所以这个文档大多数情况我默认会使用这个条件,有个别测试不到位的可能还需要慢慢完善。
请先确保您已安装了Python 2.7,并已配置好了数据库,本文档会略过这部分内容(理论上Django是可以支持MYSql、PGSQL、SQLite、Oracle等主流数据库的,但是建议不要嘬,用自己熟悉的数据库,因为数据是无价的。)
验证方法请通过python --version查看版本,以及数据库 确认用户名和密码是否登录正常

后续我争取不上requirements.txt,远期目标我个人是希望能做个dock镜像,并让它能慢慢顺着Python3和新版本的django平滑过渡上去。

## 数据库配置

数据库配置项在mis/settings.py文件中
在88-96行为Mysql数据库配置

Expand All @@ -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驱动导致的问题,所以需要先安装一个数据库驱动。

2 changes: 1 addition & 1 deletion basedata/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
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,\
Expand Down
2 changes: 1 addition & 1 deletion basedata/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
import basedata.views

urlpatterns = [
url(r"dataimport/(?P<object_id>\d+)/action", 'basedata.views.action_import'),
url(r"dataimport/(?P<object_id>\d+)/action", basedata.views.action_import),
]
10 changes: 5 additions & 5 deletions invent/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import invent.views

urlpatterns = [
url(r"stockin/(?P<object_id>\d+)/cin", 'invent.views.action_in'),
url(r"initialinventory/(?P<object_id>\d+)/cin", 'invent.views.action_init'),
url(r"stockout/(?P<object_id>\d+)/out", 'invent.views.action_out'),
url(r"warereturn/(?P<object_id>\d+)/cin", 'invent.views.action_return'),
url(r"wareadjust/(?P<object_id>\d+)/adjust", 'invent.views.action_adjust'),
url(r"stockin/(?P<object_id>\d+)/cin", invent.views.action_in),
url(r"initialinventory/(?P<object_id>\d+)/cin", invent.views.action_init),
url(r"stockout/(?P<object_id>\d+)/out", invent.views.action_out),
url(r"warereturn/(?P<object_id>\d+)/cin", invent.views.action_return),
url(r"wareadjust/(?P<object_id>\d+)/adjust", invent.views.action_adjust),
]
5 changes: 5 additions & 0 deletions mis/__init__.py
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
16 changes: 7 additions & 9 deletions mis/urls.py
Original file line number Diff line number Diff line change
@@ -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<app>\w+)/(?P<model>\w+)/(?P<object_id>\d+)/start",'workflow.views.start'),
url(r"^admin/(?P<app>\w+)/(?P<model>\w+)/(?P<object_id>\d+)/approve/(?P<operation>\d+)",'workflow.views.approve'),
url(r"^admin/(?P<app>\w+)/(?P<model>\w+)/(?P<object_id>\d+)/restart/(?P<instance>\d+)",'workflow.views.restart'),
url(r'^$', mis.views.home),
url(r"^admin/(?P<app>\w+)/(?P<model>\w+)/(?P<object_id>\d+)/start", workflow.views.start),
url(r"^admin/(?P<app>\w+)/(?P<model>\w+)/(?P<object_id>\d+)/approve/(?P<operation>\d+)", workflow.views.approve),
url(r"^admin/(?P<app>\w+)/(?P<model>\w+)/(?P<object_id>\d+)/restart/(?P<instance>\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)),
Expand Down
2 changes: 1 addition & 1 deletion selfhelp/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
import selfhelp.views

urlpatterns = [
url(r"(?P<model>\w+)/(?P<object_id>\d+)/pay", 'selfhelp.views.pay_action'),
url(r"(?P<model>\w+)/(?P<object_id>\d+)/pay", selfhelp.views.pay_action),
]

0 comments on commit a2f3d33

Please sign in to comment.