Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix JSONWidget in newer Django versions #153

Closed
wants to merge 1 commit into from

Conversation

querti
Copy link
Collaborator

@querti querti commented Jan 12, 2021

In newer Django versions TextArea's 'build_attrs' method no longer
accepts keyword arguments. The render method was modified to manually
add the 'name' argument without using the build_attrs method.

In newer Django versions TextArea's 'build_attrs' method no longer
accepts keyword arguments. The render method was modified to manually
add the 'name' argument without using the build_attrs method.
@coveralls
Copy link

Pull Request Test Coverage Report for Build 300

  • 0 of 2 (0.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.008%) to 50.317%

Changes Missing Coverage Covered Lines Changed/Added Lines %
kobo/django/forms.py 0 2 0.0%
Totals Coverage Status
Change from base Build 295: -0.008%
Covered Lines: 3095
Relevant Lines: 6151

💛 - Coveralls

@querti querti marked this pull request as ready for review January 12, 2021 11:31
@querti querti requested a review from rohanpm January 12, 2021 11:31
@@ -46,7 +46,8 @@ def clean(self, value):
class JSONWidget(django.forms.widgets.Textarea):
def render(self, name, value, attrs=None, renderer=None):
if value is None: value = ''
final_attrs = self.build_attrs(attrs, name=name)
final_attrs = self.build_attrs(attrs)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the sources of Django, it should be possible to provide extra_attrs as the second argument:

Suggested change
final_attrs = self.build_attrs(attrs)
final_attrs = self.build_attrs(attrs, {"name": name})

But the proposed solution works as well so feel free to ignore my comment

@rohanpm
Copy link
Member

rohanpm commented Jan 31, 2022

Closing as obsoleted by #164 .

@rohanpm rohanpm closed this Jan 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants