mirror of https://github.com/django/django.git
Refs #27919 -- Changed contrib widget's get_context() attrs kwarg to an arg.
Follow up to 075e93c16a
.
This commit is contained in:
parent
1e93210f1f
commit
93d0770104
|
@ -31,7 +31,7 @@ class FilteredSelectMultiple(forms.SelectMultiple):
|
||||||
self.is_stacked = is_stacked
|
self.is_stacked = is_stacked
|
||||||
super().__init__(attrs, choices)
|
super().__init__(attrs, choices)
|
||||||
|
|
||||||
def get_context(self, name, value, attrs=None):
|
def get_context(self, name, value, attrs):
|
||||||
context = super().get_context(name, value, attrs)
|
context = super().get_context(name, value, attrs)
|
||||||
context['widget']['attrs']['class'] = 'selectfilter'
|
context['widget']['attrs']['class'] = 'selectfilter'
|
||||||
if self.is_stacked:
|
if self.is_stacked:
|
||||||
|
@ -129,7 +129,7 @@ class ForeignKeyRawIdWidget(forms.TextInput):
|
||||||
self.db = using
|
self.db = using
|
||||||
super().__init__(attrs)
|
super().__init__(attrs)
|
||||||
|
|
||||||
def get_context(self, name, value, attrs=None):
|
def get_context(self, name, value, attrs):
|
||||||
context = super().get_context(name, value, attrs)
|
context = super().get_context(name, value, attrs)
|
||||||
rel_to = self.rel.model
|
rel_to = self.rel.model
|
||||||
if rel_to in self.admin_site._registry:
|
if rel_to in self.admin_site._registry:
|
||||||
|
@ -196,7 +196,7 @@ class ManyToManyRawIdWidget(ForeignKeyRawIdWidget):
|
||||||
"""
|
"""
|
||||||
template_name = 'admin/widgets/many_to_many_raw_id.html'
|
template_name = 'admin/widgets/many_to_many_raw_id.html'
|
||||||
|
|
||||||
def get_context(self, name, value, attrs=None):
|
def get_context(self, name, value, attrs):
|
||||||
context = super().get_context(name, value, attrs)
|
context = super().get_context(name, value, attrs)
|
||||||
if self.rel.model in self.admin_site._registry:
|
if self.rel.model in self.admin_site._registry:
|
||||||
# The related object is registered with the same AdminSite
|
# The related object is registered with the same AdminSite
|
||||||
|
@ -265,7 +265,7 @@ class RelatedFieldWidgetWrapper(forms.Widget):
|
||||||
return reverse("admin:%s_%s_%s" % (info + (action,)),
|
return reverse("admin:%s_%s_%s" % (info + (action,)),
|
||||||
current_app=self.admin_site.name, args=args)
|
current_app=self.admin_site.name, args=args)
|
||||||
|
|
||||||
def get_context(self, name, value, attrs=None):
|
def get_context(self, name, value, attrs):
|
||||||
from django.contrib.admin.views.main import IS_POPUP_VAR, TO_FIELD_VAR
|
from django.contrib.admin.views.main import IS_POPUP_VAR, TO_FIELD_VAR
|
||||||
rel_opts = self.rel.model._meta
|
rel_opts = self.rel.model._meta
|
||||||
info = (rel_opts.app_label, rel_opts.model_name)
|
info = (rel_opts.app_label, rel_opts.model_name)
|
||||||
|
|
|
@ -15,7 +15,7 @@ class OpenLayersWidget(Textarea):
|
||||||
"""
|
"""
|
||||||
Render an OpenLayers map using the WKT of the geometry.
|
Render an OpenLayers map using the WKT of the geometry.
|
||||||
"""
|
"""
|
||||||
def get_context(self, name, value, attrs=None):
|
def get_context(self, name, value, attrs):
|
||||||
# Update the template parameters with any attributes passed in.
|
# Update the template parameters with any attributes passed in.
|
||||||
if attrs:
|
if attrs:
|
||||||
self.params.update(attrs)
|
self.params.update(attrs)
|
||||||
|
|
|
@ -40,7 +40,7 @@ class BaseGeometryWidget(Widget):
|
||||||
logger.error("Error creating geometry from value '%s' (%s)", value, err)
|
logger.error("Error creating geometry from value '%s' (%s)", value, err)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_context(self, name, value, attrs=None):
|
def get_context(self, name, value, attrs):
|
||||||
# If a string reaches here (via a validation error on another
|
# If a string reaches here (via a validation error on another
|
||||||
# field) then just reconstruct the Geometry.
|
# field) then just reconstruct the Geometry.
|
||||||
if value and isinstance(value, str):
|
if value and isinstance(value, str):
|
||||||
|
|
Loading…
Reference in New Issue