Git Product home page Git Product logo

Comments (18)

alex avatar alex commented on August 15, 2024

Hrm, can you give an example with a traceback that triggers this?

from django-taggit.

adamrt avatar adamrt commented on August 15, 2024

Yeah np. My object has a tags field (well manager) on it. I can save a new instance with or without tags. No problem as this never hits get_db_prep_lookup. But if I try to even just save again with no modifications (or with) to the tags field, it throws the exception.
Traceback:
File "/Library/Python/2.6/site-packages/django/core/handlers/base.py" in get_response
92. response = callback(request, _callback_args, *_callback_kwargs)
File "/Library/Python/2.6/site-packages/django/contrib/admin/sites.py" in root
490. return self.model_page(request, _url.split('/', 2))
File "/Library/Python/2.6/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
44. response = view_func(request, *args, *_kwargs)
File "/Library/Python/2.6/site-packages/django/contrib/admin/sites.py" in model_page
509. return admin_obj(request, rest_of_url)
File "/Library/Python/2.6/site-packages/django/contrib/admin/options.py" in call
1098. return self.change_view(request, unquote(url))
File "/Library/Python/2.6/site-packages/django/db/transaction.py" in _commit_on_success
240. res = func(_args, *_kw)
File "/Library/Python/2.6/site-packages/django/contrib/admin/options.py" in change_view
831. form.save_m2m()
File "/Library/Python/2.6/site-packages/django/forms/models.py" in save_m2m
75. f.save_form_data(instance, cleaned_data[f.name])
File "/Library/Python/2.6/site-packages/taggit/managers.py" in save_form_data
48. getattr(instance, self.name).set(_value)
File "/Library/Python/2.6/site-packages/taggit/utils.py" in inner
11. return func(self, *args, *_kwargs)
File "/Library/Python/2.6/site-packages/taggit/managers.py" in set
121. self.clear()
File "/Library/Python/2.6/site-packages/taggit/utils.py" in inner
11. return func(self, _args, *_kwargs)
File "/Library/Python/2.6/site-packages/taggit/managers.py" in clear
133. content_type=ContentType.objects.get_for_model(self.model)).delete()
File "/Library/Python/2.6/site-packages/django/db/models/query.py" in delete
399. delete_objects(seen_objs)
File "/Library/Python/2.6/site-packages/django/db/models/query.py" in delete_objects
1037. del_query.delete_batch_related(pk_list)
File "/Library/Python/2.6/site-packages/django/db/models/sql/subqueries.py" in delete_batch_related
56. AND)
File "/Library/Python/2.6/site-packages/django/db/models/sql/where.py" in add
56. obj, params = obj.process(lookup_type, value)
File "/Library/Python/2.6/site-packages/django/db/models/sql/where.py" in process
269. params = self.field.get_db_prep_lookup(lookup_type, value)
File "/Library/Python/2.6/site-packages/taggit/managers.py" in get_db_prep_lookup
65. raise ValueError("You can't combine Tag objects and strings, pick one !")

Exception Type: ValueError at /admin/articles/article/1061/
Exception Value: You can't combine Tag objects and strings, pick one!

from django-taggit.

alex avatar alex commented on August 15, 2024

I just pushed a test that seems to test the same behavior you described, can you fork and try to add a test case that shows the issue?

from django-taggit.

adamrt avatar adamrt commented on August 15, 2024
======================================================================
ERROR: test_add_tag (taggit.tests.tests.AddTagTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Library/Python/2.6/site-packages/taggit/tests/tests.py", line 34, in test_add_tag
    apple.tags.remove('green')
  File "/Library/Python/2.6/site-packages/taggit/utils.py", line 11, in inner
    return func(self, *args, **kwargs)
  File "/Library/Python/2.6/site-packages/taggit/managers.py", line 128, in remove
    tag__name__in=tags).delete()
  File "/Library/Python/2.6/site-packages/django/db/models/query.py", line 399, in delete
    delete_objects(seen_objs)
  File "/Library/Python/2.6/site-packages/django/db/models/query.py", line 1037, in delete_objects
    del_query.delete_batch_related(pk_list)
  File "/Library/Python/2.6/site-packages/django/db/models/sql/subqueries.py", line 56, in delete_batch_related
    AND)
  File "/Library/Python/2.6/site-packages/django/db/models/sql/where.py", line 56, in add
    obj, params = obj.process(lookup_type, value)
  File "/Library/Python/2.6/site-packages/django/db/models/sql/where.py", line 269, in process
    params = self.field.get_db_prep_lookup(lookup_type, value)
  File "/Library/Python/2.6/site-packages/taggit/managers.py", line 65, in get_db_prep_lookup
    raise ValueError("You can't combine Tag objects and strings, pick one!")
ValueError: You can't combine Tag objects and strings, pick one!

======================================================================
ERROR: test_form (taggit.tests.tests.TaggableFormTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Library/Python/2.6/site-packages/taggit/tests/tests.py", line 74, in test_form
    f.save()
  File "/Library/Python/2.6/site-packages/django/forms/models.py", line 407, in save
    fail_message, commit, exclude=self._meta.exclude)
  File "/Library/Python/2.6/site-packages/django/forms/models.py", line 79, in save_instance
    save_m2m()
  File "/Library/Python/2.6/site-packages/django/forms/models.py", line 75, in save_m2m
    f.save_form_data(instance, cleaned_data[f.name])
  File "/Library/Python/2.6/site-packages/taggit/managers.py", line 48, in save_form_data
    getattr(instance, self.name).set(*value)
  File "/Library/Python/2.6/site-packages/taggit/utils.py", line 11, in inner
    return func(self, *args, **kwargs)
  File "/Library/Python/2.6/site-packages/taggit/managers.py", line 121, in set
    self.clear()
  File "/Library/Python/2.6/site-packages/taggit/utils.py", line 11, in inner
    return func(self, *args, **kwargs)
  File "/Library/Python/2.6/site-packages/taggit/managers.py", line 133, in clear
    content_type=ContentType.objects.get_for_model(self.model)).delete()
  File "/Library/Python/2.6/site-packages/django/db/models/query.py", line 399, in delete
    delete_objects(seen_objs)
  File "/Library/Python/2.6/site-packages/django/db/models/query.py", line 1037, in delete_objects
    del_query.delete_batch_related(pk_list)
  File "/Library/Python/2.6/site-packages/django/db/models/sql/subqueries.py", line 56, in delete_batch_related
    AND)
  File "/Library/Python/2.6/site-packages/django/db/models/sql/where.py", line 56, in add
    obj, params = obj.process(lookup_type, value)
  File "/Library/Python/2.6/site-packages/django/db/models/sql/where.py", line 269, in process
    params = self.field.get_db_prep_lookup(lookup_type, value)
  File "/Library/Python/2.6/site-packages/taggit/managers.py", line 65, in get_db_prep_lookup
    raise ValueError("You can't combine Tag objects and strings, pick one!")
ValueError: You can't combine Tag objects and strings, pick one!

======================================================================
FAIL: test_lookup_by_tag (taggit.tests.tests.LookupByTagTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Library/Python/2.6/site-packages/taggit/tests/tests.py", line 58, in test_lookup_by_tag
    self.assertEqual(list(Food.objects.filter(tags="red").distinct()), [apple])
AssertionError: [] != [<Food: apple>]

----------------------------------------------------------------------
Ran 3 tests in 29.757s

FAILED (failures=1, errors=2)
Destroying test database...

from django-taggit.

alex avatar alex commented on August 15, 2024

So the current tests fail for you? What version of django are you using?

from django-taggit.

adamrt avatar adamrt commented on August 15, 2024

1.1.1 - unmodified

just throwing taggit.tests into my installed apps and running 'manage.py test taggit'. tried it on a couple boxes with the same result

osx10.6 with python 2.6
debian lenny with python 2.5

from django-taggit.

alex avatar alex commented on August 15, 2024

bec0cf1 added some more debug information. Can you rerun the tests and provide the output again, I'm unable to reproduce the test failures you're getting unfortunately.

from django-taggit.

adamrt avatar adamrt commented on August 15, 2024

Ok. It has to be something on my end. I think its grappelli - but not sure how. I can build a new project with a simple app in virtualenv and taggit works perfectly and all tests pass. I then stripped everything I could out of my real project. The only things in there is one of my apps (pretty generic app) and grappelli. im gonna keep testing. sorry for wasting your time. it seems maybe grapelli is mangling the input or something

from django-taggit.

alex avatar alex commented on August 15, 2024

If you can figure out what grapelli is sending let me know and I'll see if I can work around that. I thought grapelli was just a new "theme" for the admin, but perhaps it's doing more than that.

from django-taggit.

bfirsh avatar bfirsh commented on August 15, 2024

It's wildly broken on MySQL.

http://github.com/bfirsh/django-taggit/commit/f174d93784235269ce9249d25fed037fd0c262f6

That gets some of the way, but there are still subquery issues.

from django-taggit.

alex avatar alex commented on August 15, 2024

I've applied the long patch. Let me know what other issues you're seeing (if you can file a seperate ticket that'd be great, I'm going to consider this one a grapelli issue for now).

from django-taggit.

adamrt avatar adamrt commented on August 15, 2024

Ok. Its not grappelli. I did a new clean app with grappelli and it worked fine. im also using the same 'articles' app I have with it and it seems to be working without issue (although not on my production app). There is something else. I'll keep looking.

After pulling the 'long' patch I'm getting a different error. I was actually getting this one before when I was hacking around with get_db_prep_lookup, but assumed I was just breaking something else.

(1093, "You can't specify target table 'taggit_taggeditem' for update in FROM clause")

from django-taggit.

adamrt avatar adamrt commented on August 15, 2024

Also, on a side note. All the places I'm having issues I'm running MySQL. The places where its working is SQLite3. Only reason I mention this is because of bfirsh's comment "It's wildly broken on MySQL."

from django-taggit.

alex avatar alex commented on August 15, 2024

Are you running on MySQL? If so then I've got something to start looking at.

from django-taggit.

alex avatar alex commented on August 15, 2024

Hehe, ok so it's a MySQL issue. I'm guessing the UPDATE query under mysql doesn't like the subselect. Fixing this may be tough.

from django-taggit.

bfirsh avatar bfirsh commented on August 15, 2024

Yep, that's the issue I had with MySQL. Sorry not to be much help, but I gave up and just used a simple many to many tagging system in the end.

from django-taggit.

adamrt avatar adamrt commented on August 15, 2024

ouch. this was the last little bit before launch (on the 1st). i may just have to gut the taggit out of it and go to manytomany if i cant fix today. im not gonna give up just yet though. im gonna see if i can't get it going.

from django-taggit.

alex avatar alex commented on August 15, 2024

Ok everything is working now except for queries like Food.objects.filter(tags="red"). Instead you need to do Food.objects.filter(tags__in=["red"]). I'm trying to figure out the solution inside of django-taggit, but for now everything else seems to be working. Thanks for the report (I'm closing this ticket and opening a new one for the specific issue).

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.