Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

123
Views
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 answers
Answer question

0

Try this:

  ALLImg.objects.all().values('ref_by', 'img_name')
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!