Skip to content

Commit

Permalink
Condensed some widgets code.
Browse files Browse the repository at this point in the history
  • Loading branch information
blueyed authored and timgraham committed Mar 3, 2018
1 parent 3d8fada commit 683341d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
5 changes: 1 addition & 4 deletions django/contrib/admin/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,10 +389,7 @@ def __init__(self, rel, admin_site, attrs=None, choices=(), using=None):
self.admin_site = admin_site
self.db = using
self.choices = choices
if attrs is not None:
self.attrs = attrs.copy()
else:
self.attrs = {}
self.attrs = {} if attrs is None else attrs.copy()

def get_url(self):
model = self.rel.model
Expand Down
11 changes: 3 additions & 8 deletions django/forms/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,8 @@ def _media(self):
for medium in extend:
m = m + base[medium]
return m + Media(definition)
else:
return Media(definition)
else:
return base
return Media(definition)
return base
return property(_media)


Expand All @@ -188,10 +186,7 @@ class Widget(metaclass=MediaDefiningClass):
supports_microseconds = True

def __init__(self, attrs=None):
if attrs is not None:
self.attrs = attrs.copy()
else:
self.attrs = {}
self.attrs = {} if attrs is None else attrs.copy()

def __deepcopy__(self, memo):
obj = copy.copy(self)
Expand Down

0 comments on commit 683341d

Please sign in to comment.