Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

263
Visualizações
Django: icontains over unicode string

My client is asking something very weird but that makes sense in everyday operations.

I have an user with the first name Nicolás and I am filtering through first name with the value Nicolas.

Is there a way to show up the results? Thanks!

The code I have so far

    q = request.GET['q']

    q_res = Member.objects.filter(
        Q(first_name__icontains = q)|
        Q(last_name__icontains = q)
    )
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You can use unaccent, to make accent insensitive queries. This only works with postgres, and on Django 1.8+ I believe.

If this isn't applicable to you, then you can't do this directly. One potential alternative is to store an unaccented version of the string in a new field and search by that. There's a library for getting the closest possible regular string from a unicode one.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda