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

124
Visualizações
django group by queryset in form ModelChoiceField

I have a model having image and reference field (reference is a string value). I need to filter the images list by reference, and a reference can have multiple images.

Now I'm wishing a dropdown menu having reference field values. How can I do that.

Here is the model

class AllImg(models.Model):
    ref_by = models.CharField(max_length=100)
    img_name = models.ImageField(upload_to='uploads/allimg/')

now in my view of showing the list of AllImg model i have to filter them by ref_by field. I'll set the value of the ref_by in session and show the list according to that value. And if nothing is set in that session key, all entries of AllImg model will be shown.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Try this:

  ALLImg.objects.all().values('ref_by', 'img_name')
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