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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:58:29+00:00 2026-06-10T21:58:29+00:00

Here is my Menu model: class Menu(models.Model): name = CharField(max_length=255) shop = ForeignKey(Shop) is_active

  • 0

Here is my Menu model:

class Menu(models.Model):
    name = CharField(max_length=255)
    shop = ForeignKey(Shop)
    is_active = BooleanField(default=False)

What I need is, in ShopResource, ShopResource.menu returns only the active Menu object. Because there is always 1 active Menu object.

In ShopResource, I am trying:

def dehydrate(self, bundle):
    bundle.data['menu'] = bundle.obj.menu_set.get(is_active=True)
    return bundle

But ShopResource.menu is the string representation of the active menu object. I gues, I need to serialize something.

Any idea?

  • 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-06-10T21:58:31+00:00Added an answer on June 10, 2026 at 9:58 pm

    It’s a bit hard to figure out exactly what you need and what is your current situation because you haven’t provided any details of your Resources (i.e. source code of your Resources).

    However I think that in order to get what you need you may want to specify the attribute parameter to be a callable like so:

    attribute=lambda bundle: Menu.objects.filter(shop=bundle.obj, active=True)
    

    This allows for filtering objects within the M2M relation.

    Tastypie doesn’t say a lot (see Tastypie docs) but hopefully this will get you started.

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

Sidebar

Related Questions

here is my model : class Page(models.Model): template = models.CharField(max_length=200,blank=True) self_url = models.ForeignKey('liens.Lien',null=True,blank=True) Categorie
Given following model: rails g model Menu name:string rails g model MenuHeader mh_name:string menu_id:integer
I'm trying to change the menu here from mouse over to a on click
I have built a drop-down menu here http://dev.driz.co.uk/jsonmenu/ that uses JSON to dynamically build
I look at example of dropdown menu here . Here is simplified jsfiddle example.
I am useing the superfish jquery plugin If you view the superfish menu here:
I have a menu written here which contains root elements and secondary elements. I
I'm making a pure css dropdown menu (code here: http://jsfiddle.net/SeXyv/7/ ) and I would
I am using the jQuery dynatree along with the context menu found here .
I have menu structure as show here . All item have a background img.

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.