Django集成Ueditor错误
2019-02-14 本文已影响0人
Diolog
File "D:\Software\Anaconda3\envs\MicroMall\lib\site-packages\django\forms\boundfield.py", line 93, in as_widget
renderer=self.form.renderer,
TypeError: render() got an unexpected keyword argument 'renderer'
[14/Feb/2019 11:29:11] "GET /admin/goods/goods/add/ HTTP/1.1" 500 402872
解释
This is almost certainly because of this backwards-incompatible [change in Django 2.1](https://docs.djangoproject.com/en/2.1/releases/2.1/#features-removed-in-2-1):
> * Support for `Widget.render()` methods without the `renderer` argument is removed.
You may have subclassed `django.forms.widgets.Widget` in your code, or in the code of one of your dependencies. The code may look like this:
from django.forms import widgets
class ExampleWidget(widgets.Widget):
def render(self, name, value, attrs=None):
# ...
You need to fix the method signature of `render`, so that it looks like this:
def render(self, name, value, attrs=None, renderer=None):
Have a look at [the source code of `widgets.Widget`](https://github.com/django/django/blob/master/django/forms/widgets.py) if you want to check.