def testlarge(): for i in range(2,51): t=Department() t.name="dept_" + str(i) t.parent_id=i t.save() for j in range(100): x=Department() x.name="dept_" + str(i) + "_" + str(j) x.parent=t x.save()
def get_default_dept(): """ 获取默认部门,没有则创建 """ try: dept = Department.objects.get(DeptID=1) except: try: dept = Department(id=1, name=_(u"总公司")) dept.save() except: dept = Department.objects.all()[0] return dept
def testlarge(): for i in range(2, 51): t = Department() t.name = "dept_" + str(i) t.parent_id = i t.save() for j in range(100): x = Department() x.name = "dept_" + str(i) + "_" + str(j) x.parent = t x.save()