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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:12:41+00:00 2026-05-23T23:12:41+00:00

I am using a custom model manager in addition to the default manager (

  • 0

I am using a custom model manager in addition to the default manager (objects=model.Manager()). I would like to add two __unicode__ methods to the model — one for the default manager and one for the custom manager; otherwise, the unicode throws an error for the result of the custom manager, which does not contain some of the variables used in the unicode for the default manager.

For example —

class CreditCountManager(models.Manager):
    def credit_count(self):
        ...
        return result_list

class UserProfile(models.Model):
    user = models.ForeignKey(User, unique=True)
    full_name = models.CharField(max_length=100)
    network = models.ForeignKey(Network)
    ...
    credit_count = CreditCountManager()
    objects = models.Manager()

# need something like:
def __unicode-for-default__(self):
    return "%s(%s)"%(self.user, self.network)

def __unicode-for-credit_count__(self):
    return "%s(%s)"%(other variables)

Is there a way to do this? Thank you.

  • 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-23T23:12:43+00:00Added an answer on May 23, 2026 at 11:12 pm

    Your question does not state what kind of error you have and thus is incomplete.

    Unfortunately unicode is a Python construct. You can have just one off them.

    Instead, you need to fix the place were the object is formatted to a string to use a custom method.

    E.g.

     text = obj.my_formatter()
    

    instead of

      text = u"Something " + obj
    

    If the problem is an exception risen inside unicode() method you need to write the method in such a way that the exception does not occur. E.g. don’t use uninitialized variables.

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

Sidebar

Related Questions

I am using custom model binder in ASP.NET MVC 2 that looks like this:
Quite frequently, I'm using custom Wicket components to render model objects. Objects can sometimes
I want to overwrite the custom objects model manager to only return objects a
I've managed to over-ride the default methods for a custom query in my model
Is this the only way to create custom model validation? To do it using
When using custom template for Login control , if we add control with ID
When using custom assemblies in a visual studio project. How does one check in
I am having trouble getting my model manager to behave correctly when using the
Hi I am using a custom model binder with asp.net mvc 2.0 , everything
I'm trying to add some custom filter methods to my magento module. I though

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.