I created some models using Django ORM.
class feed(models.Model):
location = models.OneToOneField('feedlocation')
class feedlocation(models.Model):
areaHash = models.CharField(max_length=100,default='')
Then I used the follow code to find out the 'feed' on the same areaHash.
Feed.objects.filter(location__areaHash__istartwith='*****')
The I got this error:
FieldError: Unsupported lookup 'istartwith' for CharField or join on the field not permitted.
What should I do to achieve this query?
This code is incorrect :
Feed.objects.filter(location__areaHash__istartwith='*****')
Try :
Feed.objects.filter(location__areaHash__istartswith='*****')
Another Workaround could be using icontains (keeping case-insensitivity as @shacker noticed) :
Feed.objects.filter(location__areaHash__icontains='*****')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With