-
Notifications
You must be signed in to change notification settings - Fork 2
/
easytest.py
36 lines (24 loc) · 873 Bytes
/
easytest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# -*- coding:utf-8 -*-
#!/usr/bin/env python
import os
import sys
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "osc.settings")
from firstapp.models import OSCUser, Book, Cat
# 初始化若干数据
# -------------
yangfan = OSCUser.objects.create(name=u'yangfan',sex=True,age=21,email=u'[email protected]')
wangrui = OSCUser()
wangrui.name = u'wangrui'
wangrui.sex = True
wangrui.email= u'[email protected]'
wangrui.blog = u'http://www.shunix.com'
wangrui.age = 18
wangrui.save()
sangbo = OSCUser.objects.create(name=u'sangbo',age=20,sex=True,email=u'[email protected]')
lady1 = OSCUser.objects.create(name=u'lady1',age=19,sex=False,email=u'[email protected]')
# --------------
book = Book.objects.create(book_name=u'The Django Book',owner=yangfan)
book.learner.add(yangfan)
book.learner.add(sangbo)
# ---------------
cat = Cat.objects.create(owner=yangfan)