TypeError execute_sql()得到一个意外的关键字参数'chunk_size'

时间:2017-12-15 14:52:09

标签: django ldap django-rest-framework

我尝试使用rest_framework运行ldapdb并获得异常:
输入:TypeError at /users/
价值:execute_sql() got an unexpected keyword argument 'chunk_size'
地点:/usr/local/lib/python3.5/dist-packages/django/db/models/query.py in __iter__, line 54

models.py:

import ldapdb.models
from ldapdb.models.fields import CharField, IntegerField

class User(ldapdb.models.Model):
  # LDAP meta-data
  base_dn = "ou=user,o=foo"
  object_classes = ['person']

  # user attributes
  uid = CharField(db_column='uid', max_length=8, primary_key=True, unique=True)
  employeeID = IntegerField(db_column='employeeID', unique=True)

  def __str__(self):
      return self.uid

  def __unicode__(self):
      return self.uid 

serializers.py:

from rest_framework import serializers
from api.models import User

class UserSerializer(serialisers.HyperlinkedModelSerializer):
  class Meta:
    model = User
    fields = ('uid', 'employeeID')

views.py

from rest_framework import generics
from api.models import User
from api.serializers import UserSerializer

class UserList(generics.ListAPIView):
  queryset = User.objects.all()
  serializer_class = UserSerializer

urls.py

from django.conf.urls import url
from api import views

urlpatterns = [
  url(r'^users/$', views.UserList.as_view()),
]

最后但并非最不重要pip freeze

  • 的Django == 2.0
  • 的django-ldapdb == 0.9.0
  • djangorestframework == 3.7.3

2 个答案:

答案 0 :(得分:1)

最新版本django-ldapdb 0.9支持Django 1.8,1.10和1.11。它不支持Django 2.0。

主分支支持Django 2.0,因为已经合并了拉取请求#133,但从那时起它还没有发布。

答案 1 :(得分:-1)

请安装较新版本

pip install django-ldapdb==1.0

现在,错误应该消失。