I have a question about Querysets in Django.
I need to do a search on a field that is a Charfield, but the search I'm doing appears to be case sensitive. And I wanted that when looking for 'Stack' the search would return a field that is 'stack overflow'. Here is the model of the class whose search will be performed.
class Node(models.Model):
objects = GChartsManager()
idnode = models.IntegerField(db_column='idSITE', primary_key=True, editable=False) # Field name made lowercase.
nome = models.CharField(db_column='NAME', max_length=45) # Field name made lowercase.
informacoes = models.CharField(db_column='INFORMATION', max_length=45, blank=True) # Field name made lowercase.
class Meta:
managed = False
db_table = 'site'
And the code I use to perform the search
Node.objects.filter(nome__contains = keyword)
The variable that contains the value to be searched is a keyword.
And I would also like to know how to create an empty queryset and "add items" to it. For example I want to do a queryset with these 2 results, I want them both to be in the same query set.
Node.objects.filter(nome__contains = 'Stack')
Node.objects.filter(nome__contains = 'internet')