Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Python-100-Days
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
huangkq
Python-100-Days
Commits
0c25a31f
Commit
0c25a31f
authored
Aug 19, 2018
by
jackfrued
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改了Django部分的代码
parent
b1bbe89e
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
117 additions
and
17 deletions
+117
-17
index.html
Day41-55/code/oa/hrs/index.html
+22
-0
0004_auto_20180815_1345.py
Day41-55/code/oa/hrs/migrations/0004_auto_20180815_1345.py
+66
-0
models.py
Day41-55/code/oa/hrs/models.py
+13
-12
settings.py
Day41-55/code/oa/oa/settings.py
+1
-1
requirements.txt
Day41-55/code/oa/requirements.txt
+9
-0
models.py
Day41-55/code/shop/cart/models.py
+1
-1
views.py
Day41-55/code/shop/cart/views.py
+3
-1
settings.py
Day41-55/code/shop/shop/settings.py
+1
-1
cart.html
Day41-55/code/shop/templates/cart.html
+1
-1
No files found.
Day41-55/code/oa/hrs/index.html
0 → 100644
View file @
0c25a31f
<!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>
\ No newline at end of file
Day41-55/code/oa/hrs/migrations/0004_auto_20180815_1345.py
0 → 100644
View file @
0c25a31f
# 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'
,
),
]
Day41-55/code/oa/hrs/models.py
View file @
0c25a31f
...
...
@@ -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_d
ept'
db_table
=
'
TbD
ept'
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'
Day41-55/code/oa/oa/settings.py
View file @
0c25a31f
...
...
@@ -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'
,
...
...
Day41-55/code/oa/requirements.txt
0 → 100644
View file @
0c25a31f
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
Day41-55/code/shop/cart/models.py
View file @
0c25a31f
Day41-55/code/shop/cart/views.py
View file @
0c25a31f
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
})
Day41-55/code/shop/shop/settings.py
View file @
0c25a31f
...
...
@@ -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/
...
...
Day41-55/code/shop/templates/cart.html
View file @
0c25a31f
...
...
@@ -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>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment