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 645843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:32:49+00:00 2026-05-13T21:32:49+00:00

I have following structure with example data: id season_id title 1 1 Intro 2

  • 0

I have following structure with example data:

id   season_id    title 
1    1            Intro
2    1            Second part
3    1            Third part
4    4            Other intro
5    4            Other second part

(don’t ask why), where season_id is always point to id of first episode of season…

What i want, to get following:

1    1            Intro
4    4            Other intro

which are first episoded for season, technically speaking – all entries with lowest season_eid

for and i am using following query to get ids of them:

Movie.objects.filter(category_type = 2).values('season_eid').annotate(models.Min('season_eid'))

and having id i can get all data for objects using django orm __in construction.

Can I make grouping / annotate and take all fields/values using only one query? values + annotate gives me only list of dictionaries, but instead of this i would like to get proper objects (lowest value/min of season_eid) with rest of fields.

  • 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-13T21:32:50+00:00Added an answer on May 13, 2026 at 9:32 pm
    Movie.objects.annotate(category_min_season = models.Min('category__season_id')).filter(season_id=category_min_season)
    

    assuming that your catgory has FK to the Movies model.

    Update:

    Actually you don’t even need annotation; thanks to the denormalised data you have stored in the table.

    You can just do:

    Model.objects.filter(id=Q(season_id))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following data structure (a list of lists) [ ['4', '21', '1',
I have following table structure: Table: Plant PlantID: Primary Key PlantName: String Table: Party
I have the following structure: class Base { } class Child : Base {
I have the following structure public class MyClass : MyBaseClass<System.Int32> { } In a
Ok, I have the following structure. Basically a plugin architecture // assembly 1 -
I have the following XML structure: <?xml version=1.0 ?> <course xml:lang=nl> <body> <item id=787900813228567
I have the following table structure CREATE TABLE `table` ( `id` int(11) NOT NULL
I have the following entity structure: public class Party { public Int32 PartyId {
I have the following class structure FlowerDAO with the fields (mapped using Hibernate): id
Say I have the following file structure: app/ app.py controllers/ __init__.py project.py plugin.py If

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.