Git Product home page Git Product logo

Comments (8)

alex avatar alex commented on July 17, 2024

I pushed some tests in 4090a28, which indicate a failure to reproduce, do these tests fail for you? What Django version?

from django-taggit.

alex avatar alex commented on July 17, 2024

Edit, a little testing shows that there's an issue with Django 1.1, but 1.2 is unaffected. This is almost definitely a result of the refactoring Carl Meyer did to the delete infrastructure, which Russ committed. I'll add a note to the docs and close this, I doubt it's possible to fix.

from django-taggit.

alex avatar alex commented on July 17, 2024

Now documented in c5cbe2e. Closing this ticket (if you happen to have a solution for 1.1 I'm happy to fix it, but I'm not sure it's possible).

from django-taggit.

rjcoelho avatar rjcoelho commented on July 17, 2024

Yes, the test fails with 0.6 and Django 1.1. Django's 1.1 delete_batch_related tries to delete the TaggedItems by calling db_prep_value on each PK (object_id).

Do you have any sugestion to a possible workaround ? Prbl is get_prep_lookup sometimes gets called with tag id and other times with objects id, and I cannot tell then apart).

FAIL: test_delete_bulk (taggit.tests.tests.TaggableManagerTestCase)

Traceback (most recent call last):
File "/mnt/wkrjc2/views/rjc_vBox_Operad_2009/vbox_dev/altitude_configurator/altitude_configurator/vendors/taggit/tests/tests.py", line 96, in test_delete_bulk
self.assert_tags_equal(kitty.tags.all(), ["feline"])
File "/mnt/wkrjc2/views/rjc_vBox_Operad_2009/vbox_dev/altitude_configurator/altitude_configurator/vendors/taggit/tests/tests.py", line 17, in assert_tags_equal
self.assertEqual(got, tags)
File "/usr/lib/python2.3/unittest.py", line 302, in failUnlessEqual
raise self.failureException,
AssertionError: [] != ['feline']

from django-taggit.

alex avatar alex commented on July 17, 2024

Unfortunately I don't see a good solution, simply replacing the bulk delete with individual deletes would probably solve it.

from django-taggit.

rjcoelho avatar rjcoelho commented on July 17, 2024

Individual delete also has the same problem. Basically Django's ORM assumes tags are many-to-many relations and tries to delete the related entries in the m2m table, just like anyother m2m relation.

From subqueries.py:
for f in cls._meta.many_to_many:
w1 = self.where_class()
db_prep_value = None
if isinstance(f, generic.GenericRelation):
from django.contrib.contenttypes.models import ContentType
ct_field = f.rel.to._meta.get_field(f.content_type_field_name)
w1.add((Constraint(None, ct_field.column, ct_field), 'exact',
ContentType.objects.get_for_model(cls).id), AND)
id_field = f.rel.to._meta.get_field(f.object_id_field_name)
db_prep_value = id_field.get_db_prep_value
for offset in range(0, len(pk_list), GET_ITERATOR_CHUNK_SIZE):
where = self.where_class()
where.add((Constraint(None, f.m2m_column_name(), f), 'in',
map(db_prep_value,
pk_list[offset : offset + GET_ITERATOR_CHUNK_SIZE])),
AND)
if w1:
where.add(w1, AND)
self.do_query(f.m2m_db_table(), where)

This adds the constraint to delete each TaggedItem but doesn't filter by content_type.

from django-taggit.

alex avatar alex commented on July 17, 2024

Hrm... I see the issue but I don't really have a solution (other than upgrade to 1.2).

from django-taggit.

rjcoelho avatar rjcoelho commented on July 17, 2024

You are right, the difference is on http://code.djangoproject.com/ticket/12953
and http://github.com/django/django/commit/836d297e68d6a63103780295adebf6eaf6779611

I cannot upgrade to Django 1.2 because I'm suck in RHEL4 (python 2.3).

from django-taggit.

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.