diff --git a/Day41-55/code/oa/hrs/index.html b/Day41-55/code/oa/hrs/index.html
new file mode 100644
index 0000000..6bb1a3b
--- /dev/null
+++ b/Day41-55/code/oa/hrs/index.html
@@ -0,0 +1,22 @@
+
+
+
+
+ Document
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Day41-55/code/oa/hrs/migrations/0004_auto_20180815_1345.py b/Day41-55/code/oa/hrs/migrations/0004_auto_20180815_1345.py
new file mode 100644
index 0000000..91f9da1
--- /dev/null
+++ b/Day41-55/code/oa/hrs/migrations/0004_auto_20180815_1345.py
@@ -0,0 +1,66 @@
+# Generated by Django 2.0.7 on 2018-08-15 05:45
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('hrs', '0003_auto_20180524_1646'),
+ ]
+
+ operations = [
+ migrations.RemoveField(
+ model_name='dept',
+ name='excellent',
+ ),
+ migrations.AlterField(
+ model_name='dept',
+ name='location',
+ field=models.CharField(db_column='dloc', max_length=10, verbose_name='部门所在地'),
+ ),
+ migrations.AlterField(
+ model_name='dept',
+ name='name',
+ field=models.CharField(db_column='dname', max_length=20, verbose_name='部门名称'),
+ ),
+ migrations.AlterField(
+ model_name='dept',
+ name='no',
+ field=models.IntegerField(db_column='deptno', primary_key=True, serialize=False, verbose_name='部门编号'),
+ ),
+ migrations.AlterField(
+ model_name='emp',
+ name='dept',
+ field=models.ForeignKey(db_column='dno', on_delete=django.db.models.deletion.PROTECT, to='hrs.Dept'),
+ ),
+ migrations.AlterField(
+ model_name='emp',
+ name='job',
+ field=models.CharField(db_column='job', max_length=10),
+ ),
+ migrations.AlterField(
+ model_name='emp',
+ name='mgr',
+ field=models.IntegerField(blank=True, null=True),
+ ),
+ migrations.AlterField(
+ model_name='emp',
+ name='name',
+ field=models.CharField(db_column='ename', max_length=20),
+ ),
+ migrations.AlterField(
+ model_name='emp',
+ name='no',
+ field=models.IntegerField(db_column='empno', primary_key=True, serialize=False),
+ ),
+ migrations.AlterModelTable(
+ name='dept',
+ table='TbDept',
+ ),
+ migrations.AlterModelTable(
+ name='emp',
+ table='TbEmp',
+ ),
+ ]
diff --git a/Day41-55/code/oa/hrs/models.py b/Day41-55/code/oa/hrs/models.py
index b3ab6c0..deb953f 100644
--- a/Day41-55/code/oa/hrs/models.py
+++ b/Day41-55/code/oa/hrs/models.py
@@ -8,27 +8,28 @@ from django.db import models
class Dept(models.Model):
- no = models.IntegerField(primary_key=True, verbose_name='部门编号')
- name = models.CharField(max_length=20, verbose_name='部门名称')
- location = models.CharField(max_length=10, verbose_name='部门所在地')
- excellent = models.BooleanField(default=0, verbose_name='是否优秀')
+ no = models.IntegerField(db_column='deptno', primary_key=True, verbose_name='部门编号')
+ name = models.CharField(db_column='dname', max_length=20, verbose_name='部门名称')
+ location = models.CharField(db_column='dloc', max_length=10, verbose_name='部门所在地')
+ # excellent = models.BooleanField(default=0, verbose_name='是否优秀')
def __str__(self):
return self.name
class Meta:
- db_table = 'tb_dept'
+ db_table = 'TbDept'
class Emp(models.Model):
- no = models.IntegerField(primary_key=True)
- name = models.CharField(max_length=20)
- job = models.CharField(max_length=10)
- mgr = models.ForeignKey('self', null=True, blank=True, on_delete=models.SET_NULL)
- # mgr = models.IntegerField(null=True, blank=True)
+ no = models.IntegerField(db_column='empno', primary_key=True)
+ name = models.CharField(db_column='ename', max_length=20)
+ job = models.CharField(db_column='job', max_length=10)
+ # mgr = models.ForeignKey('self', null=True, blank=True, on_delete=models.SET_NULL)
+ mgr = models.IntegerField(null=True, blank=True)
sal = models.DecimalField(max_digits=7, decimal_places=2)
comm = models.DecimalField(max_digits=7, decimal_places=2, null=True, blank=True)
- dept = models.ForeignKey(Dept, on_delete=models.PROTECT)
+ dept = models.ForeignKey(Dept, db_column='dno', on_delete=models.PROTECT)
class Meta:
- db_table = 'tb_emp'
+ db_table = 'TbEmp'
+
diff --git a/Day41-55/code/oa/oa/settings.py b/Day41-55/code/oa/oa/settings.py
index 5873bcc..e352eb9 100644
--- a/Day41-55/code/oa/oa/settings.py
+++ b/Day41-55/code/oa/oa/settings.py
@@ -78,7 +78,7 @@ WSGI_APPLICATION = 'oa.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
- 'NAME': 'oa',
+ 'NAME': 'HRS',
'HOST': 'localhost',
'PORT': 3306,
'USER': 'root',
diff --git a/Day41-55/code/oa/requirements.txt b/Day41-55/code/oa/requirements.txt
new file mode 100644
index 0000000..e271cd6
--- /dev/null
+++ b/Day41-55/code/oa/requirements.txt
@@ -0,0 +1,9 @@
+asn1crypto==0.24.0
+cffi==1.11.5
+cryptography==2.3
+Django==2.0.7
+idna==2.7
+pycparser==2.18
+PyMySQL==0.9.2
+pytz==2018.5
+six==1.11.0
diff --git a/Day41-55/code/shop/cart/models.py b/Day41-55/code/shop/cart/models.py
index 103ea36..e65ff97 100644
--- a/Day41-55/code/shop/cart/models.py
+++ b/Day41-55/code/shop/cart/models.py
@@ -8,7 +8,7 @@ class Goods(models.Model):
name = models.CharField(max_length=50, db_column='gname')
price = models.DecimalField(max_digits=10, decimal_places=2, db_column='gprice')
image = models.CharField(max_length=255, db_column='gimage')
-
+
class Meta:
db_table = 'tb_goods'
diff --git a/Day41-55/code/shop/cart/views.py b/Day41-55/code/shop/cart/views.py
index 7191497..dfbf6ee 100644
--- a/Day41-55/code/shop/cart/views.py
+++ b/Day41-55/code/shop/cart/views.py
@@ -1,3 +1,4 @@
+from django.core import serializers
from django.shortcuts import render, redirect
from cart.models import Goods
@@ -25,6 +26,7 @@ class ShoppingCart(object):
def __init__(self):
self.items = {}
+ self.index = 0
def add_item(self, item):
if item.goods.id in self.items:
@@ -71,5 +73,5 @@ def add_to_cart(request, id):
def show_cart(request):
- cart = request.session.get('cart', None)
+ cart = serializers.deserialize(request.session.get('cart'))
return render(request, 'cart.html', {'cart': cart})
diff --git a/Day41-55/code/shop/shop/settings.py b/Day41-55/code/shop/shop/settings.py
index b562a55..f90e37a 100644
--- a/Day41-55/code/shop/shop/settings.py
+++ b/Day41-55/code/shop/shop/settings.py
@@ -105,7 +105,7 @@ AUTH_PASSWORD_VALIDATORS = [
},
]
-SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'
+# SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'
# Internationalization
# https://docs.djangoproject.com/en/2.0/topics/i18n/
diff --git a/Day41-55/code/shop/templates/cart.html b/Day41-55/code/shop/templates/cart.html
index 86448b2..7b67433 100644
--- a/Day41-55/code/shop/templates/cart.html
+++ b/Day41-55/code/shop/templates/cart.html
@@ -32,7 +32,7 @@
商品总价 |
操作 |
- {% for item in cart.cart_items %}
+ {% for item in cart %}
{{ item.goods.name }} |
¥{{ item.goods.price }} |