115
This is almost certainly because of this backwards-incompatible change in Django 2.1:
- Support for
Widget.render()
methods without therenderer
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
if you want to check.
0
Django is looking for a default renderer which can be set in settings.py
FORM_RENDERER = 'django.forms.renderers.DjangoTemplates'
- [Django]-What is the difference between cached_property in Django vs. Python's functools?
- [Django]-Django: Group by date (day, month, year)
- [Django]-Pip install PIL fails
0
The actual issue with this problem is in as_widget() function of BoundField class located at the location:
your_env_path/lib/python3.11/site-packages/django/forms/boundfield.py
existing_code
def as_widget(self, widget=None, attrs=None, only_initial=False):
#other code
response = widget.render(
name=self.html_initial_name if only_initial else self.html_name,
value=value,
attrs=attrs,
renderer=self.form.renderer,
)
return response
#**update the above code to**
def as_widget(self, widget=None, attrs=None, only_initial=False):
#other code
try:
response = widget.render(
name=self.html_initial_name if only_initial else self.html_name,
value=value,
attrs=attrs,
renderer=self.form.renderer,
)
except:
response = widget.render(
name=self.html_initial_name if only_initial else self.html_name,
value=value,
attrs=attrs
)
return response`
- [Django]-How do I install an old version of Django on virtualenv?
- [Django]-How to limit the maximum value of a numeric field in a Django model?
- [Django]-How to check whether the user is anonymous or not in Django?
-3
Its version and signature incompatibility issue.
Go back to version β 2.0.8
pip3 install Django==2.0.8
- [Django]-Multiple Models in a single django ModelForm?
- [Django]-OneToOneField() vs ForeignKey() in Django
- [Django]-How do I pass template context information when using HttpResponseRedirect in Django?
Source:stackexchange.com