Giter Site home page Giter Site logo

Comments (4)

shwoop avatar shwoop commented on June 27, 2024

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.

shwoop avatar shwoop commented on June 27, 2024

This usage pattern works with v1.4, prior to 56e0072 was added to fix this issue.

from django-widget-tweaks.

shwoop avatar shwoop commented on June 27, 2024

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.

kmike avatar kmike commented on June 27, 2024

@bircow could you please check django-widget-tweak master - have #42 fixed your issue?

from django-widget-tweaks.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.