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

  • SEARCH
  • Home
  • 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 6339231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:36:36+00:00 2026-05-24T19:36:36+00:00

I have tree models: Tours, buses and locations Tour have more buses, buses more

  • 0

I have tree models: Tours, buses and locations
Tour have more buses, buses more locations.

I want to return json object with buses last locations for some tour.

Pseudo example:

  BUSES

    BUS1
      last_location
    /BUS1

    BUS2
      last_location
    /BUS2

    BUS3
      last_locaiton
    /BUS3

  /BUSES

tour.buses will give me buses for that tour, and bus.locations.last latest location.

I know that is no since fiction, but I don’t know how to pack this in one json object to return it 😐

  • 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-24T19:36:36+00:00Added an answer on May 24, 2026 at 7:36 pm

    You could do it like this:

    both_pieces = {
        :tour          => tour,
        :last_location => bus.locations.last
    }
    

    And then send both_pieces back as JSON. Then the client would get one JSON object with the tour and last_location objects inside it.

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

Sidebar

Related Questions

I have 2 models: MyModel ( inherits QAbstractItemModel , its tree) and MyProxyModel (
I have tree like following example, where every leaf is object. [1] |--[2] |
I have a tree in which i want the onOpen and onClose to be
I have a tree like structure created out of models using ForeignKey linkages. As
I have a tree structure of widgets e.g. collection contains models and model contains
We have two models. Ebooks HABTM Tags, where tags follows the tree behavior. For
I have a large json server response which nests models in models. I have
I have a tree of models defined in my Django app (e.g. 'a' is
I have a tree-like model where in all situations but one , I want
I have a database of 3D models. I want user can rotate the model

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.