Reputation: 806
models.py
class KeySkills(models.Model):
skills = models.TextField()
versions = models.DecimalField(decimal_places=3,null=True,blank=True,max_digits=10,default=None)
experience = models.DecimalField(decimal_places=3,null=True,blank=True,max_digits=10,default=None)
user = models.ForeignKey(access_models.SeekerRegister,on_delete=models.CASCADE,related_name='key_skills',null=True,blank=True)
def __str__(self):
return "KeySkills"
query:
KeySkills.objects.filter(skills__unaccent__icontains='python')
KeySkills.objects.filter(skills_text__search='python')
error:
File "<console>", line 1, in <module>
File "/usr/local/lib/python3.6/site-packages/django/db/models/manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/django/db/models/query.py", line 844, in filter
return self._filter_or_exclude(False, *args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/django/db/models/query.py", line 862, in _filter_or_exclude
clone.query.add_q(Q(*args, **kwargs))
File "/usr/local/lib/python3.6/site-packages/django/db/models/sql/query.py", line 1263, in add_q
clause, _ = self._add_q(q_object, self.used_aliases)
File "/usr/local/lib/python3.6/site-packages/django/db/models/sql/query.py", line 1287, in _add_q
split_subq=split_subq,
File "/usr/local/lib/python3.6/site-packages/django/db/models/sql/query.py", line 1225, in build_filter
condition = self.build_lookup(lookups, col, value)
File "/usr/local/lib/python3.6/site-packages/django/db/models/sql/query.py", line 1080, in build_lookup
lhs = self.try_transform(lhs, name)
File "/usr/local/lib/python3.6/site-packages/django/db/models/sql/query.py", line 1126, in try_transform
(name, lhs.output_field.__class__.__name__))
django.core.exceptions.FieldError: Unsupported lookup 'unaccent' for TextField or join on the field not permitted.
Here i am trying to search using django ORM queries. And tring using above two way of queries but i am getting above error .
Please have a look into my code.
Upvotes: 0
Views: 474
Reputation:
You need to add 'django.contrib.postgres' in your INSTALLED_APPS: and after that you need install the extension 'unaccent' to you database to do this execute tha query:
CREATE EXTENSION unaccent;
i did this inside pgadmin4 in execute query.
Upvotes: 0
Reputation: 6404
You need to add 'django.contrib.postgres
' in your INSTALLED_APPS
Also, try this link
Upvotes: 2