Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3942700
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:41:39+00:00 2026-05-20T00:41:39+00:00

For example, I have a model like this: Class Doggy(models.Model): name = models.CharField(u’Name’, max_length

  • 0

For example, I have a model like this:

Class Doggy(models.Model):
    name = models.CharField(u'Name', max_length = 40)
    color = models.CharField(u'Color', max_length = 20)

How can i select doggies with the same color? Or with the same name 🙂

UPD. Of course, I don’t know the name or the color. I want to.. kind of, group by their values.

UPD2. I’m trying to do something like that, but using Django:

SELECT * 
FROM table 
WHERE tablefield IN ( 
 SELECT tablefield
 FROM table 
 GROUP BY tablefield  
 HAVING (COUNT(tablefield ) > 1) 
) 

UPD3. I’d like to do it via Django ORM, without having to iterate over the objects. I just want to get rows with duplicate values for one particular field.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T00:41:40+00:00Added an answer on May 20, 2026 at 12:41 am

    Okay, apparently, there’s no way to do such thing with ORM only.

    If you have to do it, you have to use .extra() to execute needed SQL-statement (if you are using SQL database, of course)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey, I have models like this: class Galleries(models.Model): creation_date = models.DateTimeField() name = models.CharField(max_length=255,
I have models (simplified example): class Group(models.Model): name = models.CharField(max_length = 32) class Person(models.Model):
I have a model like so: class RunnerStat(models.Model): id_card= models.CharField(max_length=32) miles = models.PositiveSmallIntegerField() last_modified
I have a model like this: class Task(models.model): TASK_STATUS_CHOICES = ( (uP, u'Pending'), (uA,
I have a model which looks like this: class Example (db.Model) : row_num =
When I have a given django model class like this: class BaseClass(models.Model): some_field =
We have a model association that looks something like this: class Example < ActiveRecord::Base
I have an object model like this: class Car { public string Manufacturer; public
I'm a Django newbie who needs your help Have this database model: class Record(models.Model):
My model is something like this: public class Line { public int CatalogNumber {get;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.