Comments (18)
Hrm, can you give an example with a traceback that triggers this?
from django-taggit.
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.
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.
======================================================================
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.
So the current tests fail for you? What version of django are you using?
from django-taggit.
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.
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.
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.
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.
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.
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.
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.
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.
Are you running on MySQL? If so then I've got something to start looking at.
from django-taggit.
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.
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.
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.
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)
- Test suite fails if unidecode is installed
- Excluding tags in Model Managers causes failures HOT 1
- Wish to have more detail in serializer, looking for tags should be nested with all the items HOT 2
- `tag_kwargs` are not taken into account when `TAGGIT_CASE_INSENSITIVE` is `True`
- TaggedItemBase related_name not filling in %(app_label)s_%(class)s_items since Django 4.2 LTS? HOT 6
- Add support for initialising tags via a list on object creation HOT 1
- Add support for new async api HOT 2
- Getting this error while running tests: 'index_together' is deprecated. Use 'Meta.indexes' in 'taggit.TaggedItem' instead. HOT 5
- tag entered in Cyrillic be displayed in Latin
- Tag Ordering Inconsistent HOT 4
- Tags longer than 100 chars raise 500 error HOT 15
- Django Taggit 5.0 is not compatible with Django <4.1 HOT 4
- RTD builds are broken HOT 1
- Multiple queries when adding tags HOT 3
- Reverse query name for 'XXX' clashes
- New 5.0.0 migrations fails: Found wrong number (0) of indexes HOT 3
- DRF - Incorrectly processed Tag input string HOT 2
- Cannot query using tags__name__in HOT 1
- Ticket objects need to have a primary key value before you can access their tags HOT 1
- Add Django 5.0 Support
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-taggit.