Comments (4)
Hi, I've come across a similar issue so thought I should add my findings here.
Using django-widget-tweaks 1.4.1 (master 970bf5b)
I added the below tests, to match my use case, which seems to mirror your own, and have found that the tests pass with django 1.4 to 1.7 but begin throwing errors in django 1.8.
I will report back if I find anything further.
New tests:
diff --git a/widget_tweaks/tests.py b/widget_tweaks/tests.py
index 454064a..6ff9f83 100644
--- a/widget_tweaks/tests.py
+++ b/widget_tweaks/tests.py
@@ -318,6 +318,32 @@ class RenderFieldTagFieldReuseTest(TestCase):
self.assertEqual(res.count("class0"), 3)
self.assertEqual(res.count("bar"), 1)
+ def test_field_double_rendering_id(self):
+ res = render_form('{{ form.simple }}{% render_field form.simple id="id_1" %}{% render_field form.simple id="id_2" %}')
+ self.assertEqual(res.count("id_1"), 1)
+ self.assertEqual(res.count("id_2"), 1)
+
+ def test_field_double_rendering_id_name(self):
+ res = render_form('{{ form.simple }}{% render_field form.simple id="id_1" name="n_1" %}{% render_field form.simple id="id_2" name="n_2"%}')
+ self.assertEqual(res.count("id_1"), 1)
+ self.assertEqual(res.count("id_2"), 1)
+ self.assertEqual(res.count("n_1"), 1)
+ self.assertEqual(res.count("n_2"), 1)
+
+ def test_field_double_rendering_id_class(self):
+ res = render_form('{{ form.simple }}{% render_field form.simple id="id_1" class="c_1" %}{% render_field form.simple id="id_2" class="c_2" %}')
+ self.assertEqual(res.count("id_1"), 1)
+ self.assertEqual(res.count("id_2"), 1)
+ self.assertEqual(res.count("c_1"), 1)
+ self.assertEqual(res.count("c_2"), 1)
+
+ def test_field_double_rendering_name_class(self):
+ res = render_form('{{ form.simple }}{% render_field form.simple name="n_1" class="c_1" %}{% render_field form.simple name="n_2" class="c_2" %}')
+ self.assertEqual(res.count("n_1"), 1)
+ self.assertEqual(res.count("n_2"), 1)
+ self.assertEqual(res.count("c_1"), 1)
+ self.assertEqual(res.count("c_2"), 1)
+
class RenderFieldTagUseTemplateVariableTest(TestCase):
def test_use_template_variable_in_parametrs(self):
Failing tests, with django 1.8+:
[~/repos/django-widget-tweaks]$ ./runtests.py *[master]
......x...............x..FFF.................
======================================================================
FAIL: test_field_double_rendering_id_class (widget_tweaks.tests.RenderFieldTagFieldReuseTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/alistair/repos/django-widget-tweaks/widget_tweaks/tests.py", line 335, in test_field_double_rendering_id_class
self.assertEqual(res.count("id_1"), 1)
AssertionError: 2 != 1
======================================================================
FAIL: test_field_double_rendering_id_name (widget_tweaks.tests.RenderFieldTagFieldReuseTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/alistair/repos/django-widget-tweaks/widget_tweaks/tests.py", line 328, in test_field_double_rendering_id_name
self.assertEqual(res.count("id_1"), 1)
AssertionError: 2 != 1
======================================================================
FAIL: test_field_double_rendering_name_class (widget_tweaks.tests.RenderFieldTagFieldReuseTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/alistair/repos/django-widget-tweaks/widget_tweaks/tests.py", line 342, in test_field_double_rendering_name_class
self.assertEqual(res.count("n_1"), 1)
AssertionError: 2 != 1
----------------------------------------------------------------------
Ran 45 tests in 0.050s
FAILED (failures=3, expected failures=2)
from django-widget-tweaks.
This usage pattern works with v1.4, prior to 56e0072 was added to fix this issue.
from django-widget-tweaks.
It seems I had a separate issue with v1.4 so have had to patch v1.4.1 and create a new pull request #42 that resolves this issue without regressing issue #21
from django-widget-tweaks.
@bircow could you please check django-widget-tweak master - have #42 fixed your issue?
from django-widget-tweaks.
Related Issues (20)
- Is it possible to add is-valid class after validation HOT 3
- Do there any blockers to bump new release? HOT 13
- Test-Suite missing in tarball HOT 1
- How to use Django template variable on attr or set_data HOT 4
- setting size of a field by accessing the model field max_length HOT 1
- accessing variables in render_field tag HOT 2
- setup.py should specify python_requires HOT 1
- Can not find module name in Django installed App HOT 5
- add another filter add_valid_class?
- WIDGET_ERROR_CLASS and WIDGET_REQUIRED_CLASS via settings HOT 1
- removing "required" from form-check-input
- Does it work on FileField? HOT 2
- widget_tweaks causes 'DeprecationWarning: pkg_resources is deprecated as an API' HOT 1
- _pickle.PicklingError: Cannot pickle ResolverMatch. HOT 1
- Releasing a new version with Django 4.2 support HOT 2
- pkg_resources error in django-widget-tweaks after upgrading to Python 3.12 on my distro (Fedora 39) HOT 2
- render_field type date doesn't respect django settings
- Use Django url tag in render_field HOT 1
- [REQUEST] Have an option to use BoundField.render() instead of str(bounded_field)
- how to hook into render_field from request
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-widget-tweaks.