0
我正在爲django使用ldapdb。添加時,我必須爲新條目生成一個uid編號。爲此,我想知道如何在我的數據庫(或其他地方)中存儲相關編號,因爲django自動管理我的數據庫。因此,我有300相關的新的UID是301,我會做類似employee.uid = 301如何在django中生成和存儲相關數字
@login_required
def add(request):
if request.method == 'POST':
form = EmployeeForm(request.POST)
if form.is_valid():
employee = form.save(commit=False)
'''for property, value in vars(employee).iteritems():
print property, ": ", value'''
employee.dn = ''
employee.photo = None
employee.save()
return HttpResponseRedirect('/employees/')
else:
messages.error(request,'Damn!!!')
else:
form = EmployeeForm()
return render(request, 'employees/detail.htm', {'form':form, 'action': 'add'})