rest framework 'user_code' 是此函数请求方法的无效关键字参数:POST 请求

rest framework 'user_code' is an invalid keyword argument for this function Request Method: POST Request

我正在尝试在同一端点中保存 BDetail 时创建新的 BCodes,但是当我测试时,抛出框架 'user_code' 是此函数请求方法的无效关键字参数:POST 请求.

BCodes 模型

class BCodes(models.Model):
    user_code = models.IntegerField()
    building_code = models.CharField(max_length=10)
    oldkey = models.CharField(max_length=32, blank=True, null=True)
    date_added = models.IntegerField(blank=True, null=True)
    is_bm = models.IntegerField(blank=True, null=True)
    bm_src = models.IntegerField(blank=True, null=True)
    agents = models.ForeignKey(Agents, models.DO_NOTHING, blank=True, null=True)
    clients = models.ForeignKey('Clients', models.DO_NOTHING, blank=True, null=True)
    free_property = models.ForeignKey('FreePublishers', models.DO_NOTHING)
    approve_free_bm = models.IntegerField()

    class Meta:
        managed = False
        db_table = 'b_codes'
        unique_together = (('user_code', 'building_code'),)

B详细模型

class BDetail(models.Model):
    kind_building = models.ForeignKey('Typebuilding', models.DO_NOTHING, db_column='kind_building')
    kind_offer = models.ForeignKey('Typeoffer', models.DO_NOTHING, db_column='kind_offer')
    country = models.ForeignKey('Countries', models.DO_NOTHING, db_column='country')
    city = models.ForeignKey('Cities', models.DO_NOTHING, db_column='city')
    sector = models.ForeignKey('Sectors', models.DO_NOTHING, db_column='sector')
    zone = models.ForeignKey('ZonesStandard', models.DO_NOTHING, db_column='zone')
    address = models.CharField(max_length=100, blank=True, null=True)
    show_address = models.IntegerField()
    show_stview = models.IntegerField(blank=True, null=True)
    lat = models.FloatField(blank=True, null=True)
    lng = models.FloatField(blank=True, null=True)
    area_m = models.FloatField(blank=True, null=True)
    area_um = models.ForeignKey(AreaMetters, models.DO_NOTHING, db_column='area_um', blank=True, null=True)
    area_built = models.FloatField(blank=True, null=True)
    area_private = models.FloatField(blank=True, null=True)
    area_m_front = models.FloatField(blank=True, null=True)
    area_um_front = models.ForeignKey(AreaMetters, models.DO_NOTHING, db_column='area_um_front', blank=True, null=True)
    area_m_back = models.FloatField(blank=True, null=True)
    area_um_back = models.ForeignKey(AreaMetters, models.DO_NOTHING, db_column='area_um_back', blank=True, null=True)
    area_proximity = models.IntegerField(blank=True, null=True)
    remade = models.IntegerField(blank=True, null=True)
    remade_m = models.IntegerField(blank=True, null=True)
    remade_y = models.IntegerField(blank=True, null=True)
    is_moblied = models.IntegerField(blank=True, null=True)
    rooms = models.IntegerField(blank=True, null=True)
    bathrooms = models.IntegerField(blank=True, null=True)
    persons = models.IntegerField(blank=True, null=True)
    garages = models.IntegerField(blank=True, null=True)
    deposit = models.IntegerField(blank=True, null=True)
    antiquity = models.ForeignKey('OptionsBuildAntiquity', models.DO_NOTHING, db_column='antiquity', blank=True, null=True)
    stratum = models.CharField(max_length=50, blank=True, null=True)
    level = models.IntegerField(blank=True, null=True)
    title = models.CharField(max_length=60, blank=True, null=True)
    comments = models.TextField(blank=True, null=True)
    tags = models.TextField(blank=True, null=True)
    permalink = models.CharField(max_length=100, blank=True, null=True)
    catchment = models.IntegerField()
    date_created = models.IntegerField(blank=True, null=True)
    date_expire = models.IntegerField(blank=True, null=True)
    date_lastmodify = models.IntegerField(blank=True, null=True)
    url360deg = models.CharField(max_length=200, blank=True, null=True)
    reference = models.CharField(max_length=10, blank=True, null=True)
    expire = models.IntegerField(blank=True, null=True)
    is_made = models.IntegerField()
    is_suspended = models.IntegerField()
    suspended_date = models.IntegerField(blank=True, null=True)
    visits = models.IntegerField(blank=True, null=True)
    b_codes = models.ForeignKey(BCodes, models.DO_NOTHING, unique=True)
    zoomlevel = models.IntegerField(db_column='zoomLevel', blank=True, null=True)  # Field name made lowercase.
    radius = models.IntegerField(blank=True, null=True)

    class Meta:
        managed = False
        db_table = 'b_detail'

BCodes 序列化器

class BCodesSerializer(serializers.ModelSerializer):
    class Meta:
        model = BCodes
        extra_kwargs = {
            'building_code': {'read_only': True},
        }

    def create(self, validated_data):
        code_data = validated_data.pop('building_code')
        return BCodes.objects.create(building_code='014', **code_data)

BDetail 序列化器

bdetailFields = (
    'id', 'lat', 'lng', 'rooms', 'title',
    'comments', 'area_m', 'area_um', 'area_built',
    'area_private', 'area_m_front', 'area_um_front',
    'area_m_back', 'area_um_back', 'area_proximity',
    'rooms', 'bathrooms', 'persons', 'garages', 'deposit',
    'antiquity', 'stratum', 'level', 'permalink', 'catchment',
    'date_created', 'date_expire', 'date_lastmodify',
    'reference', 'expire', 'is_made', 'is_suspended',
    'suspended_date', 'visits', 'b_codes',
    'radius', 'zoomlevel', 'sector', 'country', 'city',
    'zone', 'kind_building', 'kind_offer'
)

class BDetailSerializerSimple(serializers.ModelSerializer):
    area_um = serializers.FloatField()
    area_um_front = serializers.FloatField()
    area_um_back = serializers.FloatField()
    antiquity = serializers.IntegerField()
    b_codes = BCodesSerializer()
    kind_building = serializers.IntegerField()
    kind_offer = serializers.IntegerField()
    country = serializers.IntegerField()
    city = serializers.IntegerField()
    sector = serializers.IntegerField()
    zone = serializers.IntegerField()

    class Meta:
        model = BDetail
        fields = bdetailFields

    def create(self, validated_data):
        code = BCodes.objects.create(**validated_data['b_codes'])
        detail_data = validated_data.pop('b_codes')
        detail = BDetail.objects.create(b_codes=code, **detail_data)
        return detail

模型视图

class BDetailList(viewsets.ModelViewSet):
    queryset = BDetail.objects.all()

    def get_object(self):
        queryset = self.get_queryset()
        obj = get_object_or_404(
            queryset,
            pk=self.kwargs['pk'],
        )
        return obj

    def get_serializer_class(self):
        if self.action == 'retrive' or self.action == 'list':
            return BDetailSerializer
        if (
            self.action == 'create'
            or self.action == 'update'
            or self.action == 'destroy'
            or self.action == 'partial_update'
        ):
            return BDetailSerializerSimple

回溯:

File "/var/www/verinmuebles/current/Env/api/local/lib/python2.7/site-packages/django/core/handlers/exception.py" in inner
  39.             response = get_response(request)

File "/var/www/verinmuebles/current/Env/api/local/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response
  187.                 response = self.process_exception_by_middleware(e, request)

File "/var/www/verinmuebles/current/Env/api/local/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response
  185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/var/www/verinmuebles/current/Env/api/local/lib/python2.7/site-packages/django/views/decorators/csrf.py" in wrapped_view
  58.         return view_func(*args, **kwargs)

File "/var/www/verinmuebles/current/Env/api/local/lib/python2.7/site-packages/rest_framework/viewsets.py" in view
  87.             return self.dispatch(request, *args, **kwargs)

File "/var/www/verinmuebles/current/Env/api/local/lib/python2.7/site-packages/rest_framework/views.py" in dispatch
  474.             response = self.handle_exception(exc)

File "/var/www/verinmuebles/current/Env/api/local/lib/python2.7/site-packages/rest_framework/views.py" in handle_exception
  434.             self.raise_uncaught_exception(exc)

File "/var/www/verinmuebles/current/Env/api/local/lib/python2.7/site-packages/rest_framework/views.py" in dispatch
  471.             response = handler(request, *args, **kwargs)

File "/var/www/verinmuebles/current/Env/api/local/lib/python2.7/site-packages/rest_framework/mixins.py" in create
  21.         self.perform_create(serializer)

File "/var/www/verinmuebles/current/Env/api/local/lib/python2.7/site-packages/rest_framework/mixins.py" in perform_create
  26.         serializer.save()

File "/var/www/verinmuebles/current/Env/api/local/lib/python2.7/site-packages/rest_framework/serializers.py" in save
  192.             self.instance = self.create(validated_data)

File "./bdetail/serializers.py" in create
  113.         detail = BDetail.objects.create(b_codes=code, **detail_data)

File "/var/www/verinmuebles/current/Env/api/local/lib/python2.7/site-packages/django/db/models/manager.py" in manager_method
  85.                 return getattr(self.get_queryset(), name)(*args, **kwargs)

File "/var/www/verinmuebles/current/Env/api/local/lib/python2.7/site-packages/django/db/models/query.py" in create
  397.         obj = self.model(**kwargs)

File "/var/www/verinmuebles/current/Env/api/local/lib/python2.7/site-packages/django/db/models/base.py" in __init__
  555.                 raise TypeError("'%s' is an invalid keyword argument for this function" % list(kwargs)[0])

Exception Type: TypeError at /v1/propiedades/
Exception Value: 'user_code' is an invalid keyword argument for this function
Request information:
USER: admin

GET: No GET data

POST: No POST data

FILES: No FILES data

COOKIES:
tabstyle = 'raw-tab'
vi_new_mg = '1'
__zlcmid = 'cHfnfGvHfuVXUV'
vi_session = 'io2rfnhjhnb6o5mphggrpckhj5'
sessionid = 'qpmhbbkm7yzgf4lwsfa5p0mxl8kq1871'
vi_login_id = 'd91b6fecb0125ef0bb7172b8ced60ced'
vi_login_email = '2c5b1b493b4ed9e648694cf64a1e073a'
csrftoken = 'HR1ec1Miobf2c1X7krU82vLEb7Pk1LZtPXQrprRdLzvQrrzfWD2vQOyI5hb3NSyo'

META:
CONTENT_LENGTH = '481'
CONTENT_TYPE = 'application/json'
CSRF_COOKIE = 'HR1ec1Miobf2c1X7krU82vLEb7Pk1LZtPXQrprRdLzvQrrzfWD2vQOyI5hb3NSyo'
DOCUMENT_ROOT = '/etc/nginx/html'
HTTP_ACCEPT = '*/*'
HTTP_ACCEPT_ENCODING = 'gzip, deflate'
HTTP_ACCEPT_LANGUAGE = 'es,en;q=0.8'
HTTP_CACHE_CONTROL = 'no-cache'
HTTP_CONNECTION = 'keep-alive'
HTTP_CONTENT_LENGTH = '481'
HTTP_CONTENT_TYPE = 'application/json'
HTTP_COOKIE = 'vi_login_email=2c5b1b493b4ed9e648694cf64a1e073a; vi_new_mg=1; vi_login_id=d91b6fecb0125ef0bb7172b8ced60ced; vi_session=io2rfnhjhnb6o5mphggrpckhj5; sessionid=qpmhbbkm7yzgf4lwsfa5p0mxl8kq1871; tabstyle=raw-tab; __zlcmid=cHfnfGvHfuVXUV; csrftoken=HR1ec1Miobf2c1X7krU82vLEb7Pk1LZtPXQrprRdLzvQrrzfWD2vQOyI5hb3NSyo'
HTTP_DNT = '1'
HTTP_HOST = 'apiix.verinmuebles.dev'
HTTP_ORIGIN = 'chrome-extension://aicmkgpgakddgnaphhhpliifpcfhicfo'
HTTP_POSTMAN_TOKEN = 'f5bb5e63-0e7d-f5c7-e2c2-10e495451f7d'
HTTP_USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36'
HTTP_X_CSRFTOKEN = 'HR1ec1Miobf2c1X7krU82vLEb7Pk1LZtPXQrprRdLzvQrrzfWD2vQOyI5hb3NSyo'
PATH_INFO = u'/v1/propiedades/'
QUERY_STRING = ''
REMOTE_ADDR = '192.168.56.1'
REMOTE_PORT = '50090'
REQUEST_METHOD = 'POST'
REQUEST_SCHEME = 'http'
REQUEST_URI = '/v1/propiedades/'
SCRIPT_NAME = u''
SERVER_NAME = 'apiix.verinmuebles.dev'
SERVER_PORT = '80'
SERVER_PROTOCOL = 'HTTP/1.1'
uwsgi.node = 'verinmuebles'
uwsgi.version = '2.0.13.1'
wsgi.errors = <open file 'wsgi_errors', mode 'w' at 0x7f6a392884b0>
wsgi.file_wrapper = ''
wsgi.input = <uwsgi._Input object at 0x7f6a392c01c8>
wsgi.multiprocess = True
wsgi.multithread = False
wsgi.run_once = False
wsgi.url_scheme = 'http'
wsgi.version = 

Settings:
Using settings module api.settings
ABSOLUTE_URL_OVERRIDES = {}
ADMINS = []
ALLOWED_HOSTS = ['*']
APPEND_SLASH = True
AUTHENTICATION_BACKENDS = [u'django.contrib.auth.backends.ModelBackend']
AUTH_PASSWORD_VALIDATORS = u'********************'
AUTH_USER_MODEL = u'auth.User'
BASE_DIR = '/var/www/verinmuebles/current/api'
CACHES = {u'default': {u'BACKEND': u'django.core.cache.backends.locmem.LocMemCache'}}
CACHE_MIDDLEWARE_ALIAS = u'default'
CACHE_MIDDLEWARE_KEY_PREFIX = u'********************'
CACHE_MIDDLEWARE_SECONDS = 600
CSRF_COOKIE_AGE = 31449600
CSRF_COOKIE_DOMAIN = None
CSRF_COOKIE_HTTPONLY = False
CSRF_COOKIE_NAME = u'csrftoken'
CSRF_COOKIE_PATH = u'/'
CSRF_COOKIE_SECURE = False
CSRF_FAILURE_VIEW = u'django.views.csrf.csrf_failure'
CSRF_HEADER_NAME = u'HTTP_X_CSRFTOKEN'
CSRF_TRUSTED_ORIGINS = []
DATABASES = {'default': {'ENGINE': 'django.db.backends.mysql', 'AUTOCOMMIT': True, 'ATOMIC_REQUESTS': False, 'NAME': 'discover_arkweb', 'CONN_MAX_AGE': 0, 'TIME_ZONE': None, 'PORT': '3306', 'HOST': 'localhost', 'USER': 'discover_ark', 'TEST': {'COLLATION': None, 'CHARSET': None, 'NAME': None, 'MIRROR': None}, 'PASSWORD': u'********************', 'OPTIONS': {}}}
DATABASE_ROUTERS = []
DATA_UPLOAD_MAX_MEMORY_SIZE = 2621440
DATA_UPLOAD_MAX_NUMBER_FIELDS = 1000
DATETIME_FORMAT = u'N j, Y, P'
DATETIME_INPUT_FORMATS = [u'%Y-%m-%d %H:%M:%S', u'%Y-%m-%d %H:%M:%S.%f', u'%Y-%m-%d %H:%M', u'%Y-%m-%d', u'%m/%d/%Y %H:%M:%S', u'%m/%d/%Y %H:%M:%S.%f', u'%m/%d/%Y %H:%M', u'%m/%d/%Y', u'%m/%d/%y %H:%M:%S', u'%m/%d/%y %H:%M:%S.%f', u'%m/%d/%y %H:%M', u'%m/%d/%y']
DATE_FORMAT = u'N j, Y'
DATE_INPUT_FORMATS = [u'%Y-%m-%d', u'%m/%d/%Y', u'%m/%d/%y', u'%b %d %Y', u'%b %d, %Y', u'%d %b %Y', u'%d %b, %Y', u'%B %d %Y', u'%B %d, %Y', u'%d %B %Y', u'%d %B, %Y']
DEBUG = True
DEBUG_PROPAGATE_EXCEPTIONS = False
DECIMAL_SEPARATOR = u'.'
DEFAULT_CHARSET = u'utf-8'
DEFAULT_CONTENT_TYPE = u'text/html'
DEFAULT_EXCEPTION_REPORTER_FILTER = u'django.views.debug.SafeExceptionReporterFilter'
DEFAULT_FILE_STORAGE = u'django.core.files.storage.FileSystemStorage'
DEFAULT_FROM_EMAIL = u'webmaster@localhost'
DEFAULT_INDEX_TABLESPACE = u''
DEFAULT_TABLESPACE = u''
DISALLOWED_USER_AGENTS = []
EMAIL_BACKEND = u'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = u'localhost'
EMAIL_HOST_PASSWORD = u'********************'
EMAIL_HOST_USER = u''
EMAIL_PORT = 25
EMAIL_SSL_CERTFILE = None
EMAIL_SSL_KEYFILE = u'********************'
EMAIL_SUBJECT_PREFIX = u'[Django] '
EMAIL_TIMEOUT = None
EMAIL_USE_SSL = False
EMAIL_USE_TLS = False
FILE_CHARSET = u'utf-8'
FILE_UPLOAD_DIRECTORY_PERMISSIONS = None
FILE_UPLOAD_HANDLERS = [u'django.core.files.uploadhandler.MemoryFileUploadHandler', u'django.core.files.uploadhandler.TemporaryFileUploadHandler']
FILE_UPLOAD_MAX_MEMORY_SIZE = 2621440
FILE_UPLOAD_PERMISSIONS = None
FILE_UPLOAD_TEMP_DIR = None
FIRST_DAY_OF_WEEK = 0
FIXTURE_DIRS = []
FORCE_SCRIPT_NAME = None
FORMAT_MODULE_PATH = None
IGNORABLE_404_URLS = []
INSTALLED_APPS = ['bdetail.apps.BdetailConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'rest_framework']
INTERNAL_IPS = []
LANGUAGES = [(u'af', u'Afrikaans'), (u'ar', u'Arabic'), (u'ast', u'Asturian'), (u'az', u'Azerbaijani'), (u'bg', u'Bulgarian'), (u'be', u'Belarusian'), (u'bn', u'Bengali'), (u'br', u'Breton'), (u'bs', u'Bosnian'), (u'ca', u'Catalan'), (u'cs', u'Czech'), (u'cy', u'Welsh'), (u'da', u'Danish'), (u'de', u'German'), (u'dsb', u'Lower Sorbian'), (u'el', u'Greek'), (u'en', u'English'), (u'en-au', u'Australian English'), (u'en-gb', u'British English'), (u'eo', u'Esperanto'), (u'es', u'Spanish'), (u'es-ar', u'Argentinian Spanish'), (u'es-co', u'Colombian Spanish'), (u'es-mx', u'Mexican Spanish'), (u'es-ni', u'Nicaraguan Spanish'), (u'es-ve', u'Venezuelan Spanish'), (u'et', u'Estonian'), (u'eu', u'Basque'), (u'fa', u'Persian'), (u'fi', u'Finnish'), (u'fr', u'French'), (u'fy', u'Frisian'), (u'ga', u'Irish'), (u'gd', u'Scottish Gaelic'), (u'gl', u'Galician'), (u'he', u'Hebrew'), (u'hi', u'Hindi'), (u'hr', u'Croatian'), (u'hsb', u'Upper Sorbian'), (u'hu', u'Hungarian'), (u'ia', u'Interlingua'), (u'id', u'Indonesian'), (u'io', u'Ido'), (u'is', u'Icelandic'), (u'it', u'Italian'), (u'ja', u'Japanese'), (u'ka', u'Georgian'), (u'kk', u'Kazakh'), (u'km', u'Khmer'), (u'kn', u'Kannada'), (u'ko', u'Korean'), (u'lb', u'Luxembourgish'), (u'lt', u'Lithuanian'), (u'lv', u'Latvian'), (u'mk', u'Macedonian'), (u'ml', u'Malayalam'), (u'mn', u'Mongolian'), (u'mr', u'Marathi'), (u'my', u'Burmese'), (u'nb', u'Norwegian Bokm\xe5l'), (u'ne', u'Nepali'), (u'nl', u'Dutch'), (u'nn', u'Norwegian Nynorsk'), (u'os', u'Ossetic'), (u'pa', u'Punjabi'), (u'pl', u'Polish'), (u'pt', u'Portuguese'), (u'pt-br', u'Brazilian Portuguese'), (u'ro', u'Romanian'), (u'ru', u'Russian'), (u'sk', u'Slovak'), (u'sl', u'Slovenian'), (u'sq', u'Albanian'), (u'sr', u'Serbian'), (u'sr-latn', u'Serbian Latin'), (u'sv', u'Swedish'), (u'sw', u'Swahili'), (u'ta', u'Tamil'), (u'te', u'Telugu'), (u'th', u'Thai'), (u'tr', u'Turkish'), (u'tt', u'Tatar'), (u'udm', u'Udmurt'), (u'uk', u'Ukrainian'), (u'ur', u'Urdu'), (u'vi', u'Vietnamese'), (u'zh-hans', u'Simplified Chinese'), (u'zh-hant', u'Traditional Chinese')]
LANGUAGES_BIDI = [u'he', u'ar', u'fa', u'ur']
LANGUAGE_CODE = 'en-us'
LANGUAGE_COOKIE_AGE = None
LANGUAGE_COOKIE_DOMAIN = None
LANGUAGE_COOKIE_NAME = u'django_language'
LANGUAGE_COOKIE_PATH = u'/'
LOCALE_PATHS = []
LOGGING = {}
LOGGING_CONFIG = u'logging.config.dictConfig'
LOGIN_REDIRECT_URL = u'/accounts/profile/'
LOGIN_URL = u'/accounts/login/'
LOGOUT_REDIRECT_URL = None
MANAGERS = []
MEDIA_ROOT = u''
MEDIA_URL = u''
MESSAGE_STORAGE = u'django.contrib.messages.storage.fallback.FallbackStorage'
MIDDLEWARE = ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware']
MIDDLEWARE_CLASSES = [u'django.middleware.common.CommonMiddleware', u'django.middleware.csrf.CsrfViewMiddleware']
MIGRATION_MODULES = {}
MONTH_DAY_FORMAT = u'F j'
NUMBER_GROUPING = 0
PASSWORD_HASHERS = u'********************'
PASSWORD_RESET_TIMEOUT_DAYS = u'********************'
PREPEND_WWW = False
REST_FRAMEWORK = {'PAGE_SIZE': 10}
ROOT_URLCONF = 'api.urls'
SECRET_KEY = u'********************'
SECURE_BROWSER_XSS_FILTER = False
SECURE_CONTENT_TYPE_NOSNIFF = False
SECURE_HSTS_INCLUDE_SUBDOMAINS = False
SECURE_HSTS_SECONDS = 0
SECURE_PROXY_SSL_HEADER = None
SECURE_REDIRECT_EXEMPT = []
SECURE_SSL_HOST = None
SECURE_SSL_REDIRECT = False
SERVER_EMAIL = u'root@localhost'
SESSION_CACHE_ALIAS = u'default'
SESSION_COOKIE_AGE = 1209600
SESSION_COOKIE_DOMAIN = None
SESSION_COOKIE_HTTPONLY = True
SESSION_COOKIE_NAME = u'sessionid'
SESSION_COOKIE_PATH = u'/'
SESSION_COOKIE_SECURE = False
SESSION_ENGINE = u'django.contrib.sessions.backends.db'
SESSION_EXPIRE_AT_BROWSER_CLOSE = False
SESSION_FILE_PATH = None
SESSION_SAVE_EVERY_REQUEST = False
SESSION_SERIALIZER = u'django.contrib.sessions.serializers.JSONSerializer'
SETTINGS_MODULE = 'api.settings'
SHORT_DATETIME_FORMAT = u'm/d/Y P'
SHORT_DATE_FORMAT = u'm/d/Y'
SIGNING_BACKEND = u'django.core.signing.TimestampSigner'
SILENCED_SYSTEM_CHECKS = []
STATICFILES_DIRS = []
STATICFILES_FINDERS = [u'django.contrib.staticfiles.finders.FileSystemFinder', u'django.contrib.staticfiles.finders.AppDirectoriesFinder']
STATICFILES_STORAGE = u'django.contrib.staticfiles.storage.StaticFilesStorage'
STATIC_ROOT = '/var/www/verinmuebles/current/api/static'
STATIC_URL = '/static/'
TEMPLATES = [{'DIRS': [], 'APP_DIRS': True, 'OPTIONS': {'context_processors': ['django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages']}, 'BACKEND': 'django.template.backends.django.DjangoTemplates'}]
TEST_NON_SERIALIZED_APPS = []
TEST_RUNNER = u'django.test.runner.DiscoverRunner'
THOUSAND_SEPARATOR = u','
TIME_FORMAT = u'P'
TIME_INPUT_FORMATS = [u'%H:%M:%S', u'%H:%M:%S.%f', u'%H:%M']
TIME_ZONE = 'UTC'
USE_ETAGS = False
USE_I18N = True
USE_L10N = True
USE_THOUSAND_SEPARATOR = False
USE_TZ = True
USE_X_FORWARDED_HOST = False
USE_X_FORWARDED_PORT = False
WSGI_APPLICATION = 'api.wsgi.application'
X_FRAME_OPTIONS = u'SAMEORIGIN'
YEAR_MONTH_FORMAT = u'F Y'

原始请求

{
    "lat": 1000,
    "lng": 1000,
    "rooms": 2,
    "catchment": 2,
    "area_um_back": 2,
    "area_um_front": 2,
    "area_um": 2,
    "zoomlevel": 10,
    "radius": 10,
    "is_suspended": 1,
    "is_made": 1,
    "antiquity": 1,
    "sector": 2,
    "city": "1",
    "zone": 2,
    "country": 2,
    "kind_offer": 3,
    "kind_building": 3,
    "b_codes": {
        "agents": 10,
        "user_code": 1346,
        "free_property": 12,
        "approve_free_bm": 2
    }
}

错误在 BDetailSerializerSimple 的创建方法中

之前

def create(self, validated_data):
        code = BCodes.objects.create(**validated_data['b_codes'])
        detail_data = validated_data.pop('b_codes')
        detail = BDetail.objects.create(b_codes=code, **detail_data)
        return detail

之后
def create(self, validated_data):
        b_codes_data = validated_data.pop('b_codes')
        code = BCodes.objects.create(**b_codes_data)
        detail = BDetail.objects.create(b_codes=code, **validated_data)
        return detail