“ update_fields”是此函数的无效关键字参数

萨拉斯·阿克

我在保存Django模态表单时收到此错误消息

'update_fields'是此函数的无效关键字参数,我不知道为什么此错误会在更新和插入操作中出现相同的错误,这是我的查看代码

form = CompanyForm(request.POST, instance=company)
if form.is_valid():
       company = form.save(request.user)

我的模态形式

class CompanyForm(forms.ModelForm):
    class Meta:
        model = Company
        fields = ('name','organisation', 'currency')

    def __init__(self, *args, **kwargs):
        super(CompanyForm, self).__init__(*args, **kwargs)
        if self.instance.id:
            self.fields['currency'].widget.attrs['readonly'] = True

    def clean_currency(self):
        if self.instance.id:
            return self.instance.currency
        return self.cleaned_data.get('currency')

    def save(self, operator, commit=True):
        company = super(CompanyForm, self).save(commit=False)
        company.operator = operator
        company.save()
        return company

堆栈跟踪在下面给出

环境:

Request Method: POST
Request URL: http://stage.site.net/manage/companies/1/edit/

Django Version: 1.9
Python Version: 2.7.9
Installed Applications:
('django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.sites',
 'django.contrib.admindocs',
 'django.contrib.staticfiles',
 'django.contrib.postgres',
 'axes',
 'mailer',
 'compressor',
 'lib',
 'cpanel',
 'systems',
 'profiles',
 'frontend',
 'documents',
 'finance',
 'themes',
 'media',
 'plugins',
 'rosetta',
 'debug_toolbar')
Installed Middleware:
('debug_toolbar.middleware.DebugToolbarMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'middlewares.SiteMiddleWare',
 'middlewares.StripHtmlCommentsMiddleware')



Traceback:

File "/var/django_apps/site/cms/env/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  149.                     response = self.process_exception_by_middleware(e, request)

File "/var/django_apps/site/cms/env/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  147.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/var/django_apps/site/cms/env/local/lib/python2.7/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
  23.                 return view_func(request, *args, **kwargs)

File "./apps/adminmanage/views.py" in company_edit
  117.             company = form.save(request.user)

File "./apps/systems/forms.py" in save
  136.         company.save()

File "/var/django_apps/site/cms/env/local/lib/python2.7/site-packages/django/db/models/base.py" in save
  700.                        force_update=force_update, update_fields=update_fields)

File "/var/django_apps/site/cms/env/local/lib/python2.7/site-packages/django/db/models/base.py" in save_base
  737.                                    update_fields=update_fields, raw=raw, using=using)

File "/var/django_apps/site/cms/env/local/lib/python2.7/site-packages/django/dispatch/dispatcher.py" in send
  192.             response = receiver(signal=self, sender=sender, **named)

File "/var/django_apps/site/cms/env/local/lib/python2.7/site-packages/django/db/models/base.py" in __init__
  443.                 raise TypeError("'%s' is an invalid keyword argument for this function" % list(kwargs)[0])

Exception Type: TypeError at /manage/companies/1/edit/
Exception Value: 'update_fields' is an invalid keyword argument for this function
萨拉斯·阿克

解决了问题,导致接收方出现此问题,

@receiver(models.signals.post_save)

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

'uuid'是此函数的无效关键字参数

来自分类Dev

Django TypeError(“'%s'是此函数的无效关键字参数”)

来自分类Dev

TypeError:“ cmp”是此函数的无效关键字参数

来自分类Dev

'categories'是此函数django的无效关键字参数

来自分类Dev

Django TypeError(“'%s'是此函数的无效关键字参数”)

来自分类Dev

Django:TypeError:“ x”是此函数的无效关键字参数

来自分类Dev

类型错误:“ndim”是此函数的无效关键字参数

来自分类Dev

TypeError : 'manuscript' 是此函数的无效关键字参数

来自分类Dev

“title”是此函数的无效关键字参数

来自分类Dev

类型错误:“数据”是此函数的无效关键字参数

来自分类Dev

DataDriver库方法_stats_suite失败:TypeError:“ encoding”是此函数的无效关键字参数

来自分类Dev

/ signup'user_password'中的Django TypeError是此函数的无效关键字参数

来自分类Dev

Django-TypeError:“体裁”是此函数的无效关键字参数

来自分类Dev

参数c#中此关键字的用法

来自分类Dev

对象内函数中的此关键字

来自分类Dev

类内的jquery函数混淆了此关键字

来自分类Dev

在函数中使用此关键字设置属性

来自分类Dev

为什么在构造函数中使用此关键字

来自分类Dev

此关键字位于对象文字的嵌套函数中

来自分类Dev

关键字搜索无效

来自分类Dev

转到“此”关键字

来自分类Dev

函数参数前的class关键字是什么?

来自分类Dev

Python-函数继承-更改关键字参数

来自分类Dev

将哈希传递给接受关键字参数的函数

来自分类Dev

如何使python内置函数支持关键字参数?

来自分类Dev

函数中带有*&参数的常量关键字。

来自分类Dev

具有多个参数或关键字的JavaScript Filter()函数

来自分类Dev

BERT调用函数中的关键字参数

来自分类Dev

参数类型的构造函数中“ where”关键字的用途

Related 相关文章

  1. 1

    'uuid'是此函数的无效关键字参数

  2. 2

    Django TypeError(“'%s'是此函数的无效关键字参数”)

  3. 3

    TypeError:“ cmp”是此函数的无效关键字参数

  4. 4

    'categories'是此函数django的无效关键字参数

  5. 5

    Django TypeError(“'%s'是此函数的无效关键字参数”)

  6. 6

    Django:TypeError:“ x”是此函数的无效关键字参数

  7. 7

    类型错误:“ndim”是此函数的无效关键字参数

  8. 8

    TypeError : 'manuscript' 是此函数的无效关键字参数

  9. 9

    “title”是此函数的无效关键字参数

  10. 10

    类型错误:“数据”是此函数的无效关键字参数

  11. 11

    DataDriver库方法_stats_suite失败:TypeError:“ encoding”是此函数的无效关键字参数

  12. 12

    / signup'user_password'中的Django TypeError是此函数的无效关键字参数

  13. 13

    Django-TypeError:“体裁”是此函数的无效关键字参数

  14. 14

    参数c#中此关键字的用法

  15. 15

    对象内函数中的此关键字

  16. 16

    类内的jquery函数混淆了此关键字

  17. 17

    在函数中使用此关键字设置属性

  18. 18

    为什么在构造函数中使用此关键字

  19. 19

    此关键字位于对象文字的嵌套函数中

  20. 20

    关键字搜索无效

  21. 21

    转到“此”关键字

  22. 22

    函数参数前的class关键字是什么?

  23. 23

    Python-函数继承-更改关键字参数

  24. 24

    将哈希传递给接受关键字参数的函数

  25. 25

    如何使python内置函数支持关键字参数?

  26. 26

    函数中带有*&参数的常量关键字。

  27. 27

    具有多个参数或关键字的JavaScript Filter()函数

  28. 28

    BERT调用函数中的关键字参数

  29. 29

    参数类型的构造函数中“ where”关键字的用途

热门标签

归档