3
I have a question about Querysets in Django.
I need to search a field that’s a Charfield, only the research I’m doing appears to be case sensitive. And I wanted that when searching for 'Stack' the search returns 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)
Keyword being the variable containing the value to be searched.
And I would also like to know how to create an empty queryset and "add items" to it. For example I want to make a queryset with these 2 results, I want both to be in the same query set.
Node.objects.filter(nome__contains = 'Stack')
Node.objects.filter(nome__contains = 'internet')
Very well detailed, I use another framework, but I will take a look at this now due to this part of Models +1
– Guilherme Nascimento