修改了Django部分的代码
parent
b1bbe89ed9
commit
0c25a31f6f
|
@ -0,0 +1,22 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Document</title>
|
||||
<style type="text/css">
|
||||
#container {
|
||||
width: 960px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
#container iframe {
|
||||
opacity: 0.5;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
<iframe src="http://www.jd.com" width="960" height="800"></iframe>
|
||||
</div>
|
||||
<textarea rows="10" cols="50"></textarea>
|
||||
</body>
|
||||
</html>
|
|
@ -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',
|
||||
),
|
||||
]
|
|
@ -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'
|
||||
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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
|
|
@ -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'
|
||||
|
|
|
@ -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})
|
||||
|
|
|
@ -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/
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
<th>商品总价</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
{% for item in cart.cart_items %}
|
||||
{% for item in cart %}
|
||||
<tr>
|
||||
<td class="name">{{ item.goods.name }}</td>
|
||||
<td class="price">¥{{ item.goods.price }}</td>
|
||||
|
|
Loading…
Reference in New Issue