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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:57:04+00:00 2026-05-27T07:57:04+00:00

I have a static Object called Module . One of the attributes for a

  • 0

I have a static Object called Module. One of the attributes for a Module object is a 'name'. I have a database table called Section that saves the Module key in a column.

I’d like to fetch the objects from that table and sort by the name of the Module they are related with.

Most of the time, when I reference the Module object, it’s like this: section.module.module_object.name

The model is:

class Section(models.Model):
    page = models.ForeignKey(Page)
    module = models.CharField(db_index=True, max_length=50, choices=[(k, '%s %s' % (s.service, s.name)) for k, s in MODULES.iteritems()])

I’ve tried this:

navigation_links = sorted(navigation_links.values(), key=lambda m: m['module'].module_object.name)

but I get the error AttributeError: 'unicode' object has no attribute 'module_object'

UPDATE: Here is the module object:

class Module(object):

    def __init__(self, key, name):
        self.key = key
        self.name = name

# ... list of a lot of ALL_MODULES

#dict of the above list
MODULES = dict([(s.key, s) for s in ALL_MODULES])
  • 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-27T07:57:05+00:00Added an answer on May 27, 2026 at 7:57 am

    From your code I infer that MODULES is a dictionary of your Module objects, indexed by value by which they are saved in the database. These objects have a name property, so if you modify your example to fetch the object from this dictionary by saved name, you should get what you need:

    navigation_links = sorted(navigation_links.values(), 
                              key=lambda m: MODULES[m['module']].name)
    

    Of course, this is all based on my guesses about your code. If this doesn’t work, please provide more information about section and module_object variables.

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

Sidebar

Related Questions

I have the C# method private static string TypeNameLower(object o) { return o.GetType().Name.ToLower(); }
I have an object obj that is passed into a helper method. public static
I have a user object called UserSystem, which is created by a static factory
I have a static object defined in my logging class, along the lines of:
I have some code where I use a thread static object in C#. [ThreadStatic]
I have the following method public static void SerializeToXMLFile(Object obj,Type type, string fileName) {
I currently have a function: public static Attribute GetAttribute(MemberInfo Member, Type AttributeType) { Object[]
I have several service classes that have static methods and offer a service to
I have a class called DataStructures where I have a set of public static
I have a class called Product in my Business object and in another class

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.