class Team(models.Model):
name = models.CharField(max_length=200)
Then I create some team and try to look for it with iexact match:
tt = Team(name='English')
tt.save()
Team.objects.filter(name__iexact=tt.name.lower()) # this returns the
list containing my initial team object
When I do the same from the terminal and create the Team object by
passing the unicode symbols (e.g. u'<Russian symbols>'), it works the
same.
But when created from the admin interface, the data is not saved in
unicode (at least it looks like so, cause the field is varchar).
And then name__iexact=name.lower() does not work.
The question is: is it possible to fix the issue so that
1) the objects could still be created with admin interfaces with
minimal changes (m.b. some additional arguments to the model fields?)
2) the case-insensitive lookups start working without any additional
magic (so, I do not have to think about unicode and non-unicode data
when filtering the DB)
Hello.
Consider I have a simple model
class Team(models.Model):
name = models.CharField(max_length=200)
Then I create some team and try to look for it with iexact match:
tt = Team(name='English')
tt.save()
Team.objects.filter(name__iexact=tt.name.lower()) # this returns the
list containing my initial team object
When I do the same from the terminal and create the Team object by
passing the unicode symbols (e.g. u'<Russian symbols>'), it works the
same.
But when created from the admin interface, the data is not saved in
unicode (at least it looks like so, cause the field is varchar).
And then name__iexact=name.lower() does not work.