Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Django 2.0 and tags__name__in=[""] error #511

Closed
TheProrok29 opened this issue Dec 12, 2017 · 7 comments
Closed

Django 2.0 and tags__name__in=[""] error #511

TheProrok29 opened this issue Dec 12, 2017 · 7 comments

Comments

@TheProrok29
Copy link

TheProrok29 commented Dec 12, 2017

In Django 2.0, filtering using tags__name__in doesen't work.
When try to use this function for example:
published= Post.published.all() and then
published.filter(tags__name__in=['music'])

I have this:
Traceback (most recent call last):
File "/home/prorok/Django/Django/lib/python3.6/site-packages/django/core/handlers/exception.py", line 35, in inner
response = get_response(request)
File "/home/prorok/Django/Django/lib/python3.6/site-packages/django/core/handlers/base.py", line 128, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/home/prorok/Django/Django/lib/python3.6/site-packages/django/core/handlers/base.py", line 126, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/prorok/Django/mysite/blog/views.py", line 95, in post_detail
similar_posts = Post.published.filter(tags__in=post_tags_ids).exclude(id=post.id)
File "/home/prorok/Django/Django/lib/python3.6/site-packages/django/db/models/manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/prorok/Django/Django/lib/python3.6/site-packages/django/db/models/query.py", line 836, in filter
return self._filter_or_exclude(False, *args, **kwargs)
File "/home/prorok/Django/Django/lib/python3.6/site-packages/django/db/models/query.py", line 854, in _filter_or_exclude
clone.query.add_q(Q(*args, **kwargs))
File "/home/prorok/Django/Django/lib/python3.6/site-packages/django/db/models/sql/query.py", line 1252, in add_q
clause, _ = self._add_q(q_object, self.used_aliases)
File "/home/prorok/Django/Django/lib/python3.6/site-packages/django/db/models/sql/query.py", line 1276, in _add_q
split_subq=split_subq,
File "/home/prorok/Django/Django/lib/python3.6/site-packages/django/db/models/sql/query.py", line 1152, in build_filter
lookups, parts, reffed_expression = self.solve_lookup_type(arg)
File "/home/prorok/Django/Django/lib/python3.6/site-packages/django/db/models/sql/query.py", line 1015, in solve_lookup_type
_, field, _, lookup_parts = self.names_to_path(lookup_splitted, self.get_meta())
File "/home/prorok/Django/Django/lib/python3.6/site-packages/django/db/models/sql/query.py", line 1390, in names_to_path
pathinfos = field.get_path_info(filtered_relation)
TypeError: get_path_info() takes 1 positional argument but 2 were given

I used #509.

@jdufresne
Copy link
Member

I was unable to reproduce. Could you provide more details about your minimal example or write a failing test for the taggit test suite?

@TheProrok29
Copy link
Author

Sorry for my bad english language.I attach a short description of the problem in .pdf
file. I'am new in Django and Python so now I can't write a good tests. It will change in future.
Django 2.pdf

@ajf-sa
Copy link

ajf-sa commented Dec 17, 2017

Request Method: GET
http://localhost:8000/stores/api/v1/itm/tgs/
2.0
TypeError
get_path_info() takes 1 positional argument but 2 were given
C:\Users\user\Documents\projects\v3\lib\site-packages\django\db\models\sql\query.py in names_to_path, line 1390
C:\Users\user\Documents\projects\v3\Scripts\python.exe 3.6.1
['C:\\Users\\user\\Dropbox\\projects\\global_api',  
'C:\\Users\\user\\Documents\\projects\\v3\\Scripts\\python36.zip', 
 'C:\\Users\\user\\Documents\\projects\\v3\\DLLs', 
 'C:\\Users\\user\\Documents\\projects\\v3\\lib',
  'C:\\Users\\user\\Documents\\projects\\v3\\Scripts',
  'C:\\Python36\\Lib',  
'C:\\Python36\\DLLs',  
'C:\\Users\\user\\Documents\\projects\\v3', 
 'C:\\Users\\user\\Documents\\projects\\v3\\lib\\site-packages']

models.py

class Item(ActiveAbstract, ContentTypeAbstract, UUIdAbstract):
    name = models.CharField(max_length=255)
    descr = models.TextField(null=True, blank=True)
    thumbnail = models.IntegerField(default=0)
    images = GenericRelation(Image)
    tags = TaggableManager(blank=True)
    def as_dict(self):
        return {
            'uuid': self.uuid,
            'name': self.name,
            'descr': self.descr,
            'thumbnail': self.thumbnail,
            'images': get_dicts(self.images),
            'tags': [(obj.name, obj.slug) for obj in self.tags.all()]
        }

api_views.py

def get_tags(request):
  items = Item.objects.filter(tags__name__in=['android','iphone'])
  ctx = [obj.as_dict() for obj in items]
  return HttpResponse(json.dumps(ctx),content_type='application/json')

Mon, 18 Dec 2017 01:02:18 +0300

python@3.6.1 django@2.0

it works fine with django@1.11
after update to djagno@2.0 something happen

@DavidMares22
Copy link

same error here with django 2.0

@jdufresne
Copy link
Member

Can you confirm you've included the changes from #509? The error suggests to me that is is missing.

@DavidMares22
Copy link

oh you're right , i used pip install django-taggit today, but my version doesn't have the changes from #509

@jdufresne
Copy link
Member

Thanks for testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants