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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:39:00+00:00 2026-06-09T12:39:00+00:00

I have many Models linked to User and I’d like my templates to always

  • 0

I have many Models linked to User and I’d like my templates to always display his full_name if available. Is there a way to change the default User __unicode__() ? Or is there another way to do it ?

I have a profile model registered where I can define the __unicode__(), should I link all my models to it ? Seems not a good idea to me.


Imagine I need to display the form for this object

class UserBagde
    user = model.ForeignKey(User)
    badge = models.ForeignKey(Bagde)

I will have to select box with __unicodes__ of each object, won’t I ?
How can I have full names in the user’s one ?

  • 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-09T12:39:02+00:00Added an answer on June 9, 2026 at 12:39 pm

    Try this:

    User.full_name = property(lambda u: u"%s %s" % (u.first_name, u.last_name))
    

    EDIT

    Apparently what you want already exists..

    https://docs.djangoproject.com/en/dev/ref/contrib/auth/#django.contrib.auth.models.User.get_full_name

    ALSO

    if its imperative that the unicode function be replaced:

    def user_new_unicode(self):
        return self.get_full_name()
    
    # Replace the __unicode__ method in the User class with out new implementation
    User.__unicode__ = user_new_unicode 
    
    # or maybe even
    User.__unicode__ = User.get_full_name()
    

    Fallback if name fields are empty

    def user_new_unicode(self):
        return self.username if self.get_full_name() == "" else self.get_full_name()
    
    # Replace the __unicode__ method in the User class with out new implementation
    User.__unicode__ = user_new_unicode 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using rails 3.2. I have many to many type of models. Is there
Given models User and Comments being populated such that a user may have many
I have a User model and a Company model linked like this: class User
I have two models that are linked by another model through a many to
In the Rails application I’m currently developing I have many request models. We are
I have models Product and Category . Category can have many products. ( Product
I have two models - Tenant and User, each tenant will have_many users and
I've got two models Category and Item. Category can have many items and item
I have 2 models that have a many-to-many association(an Event has many Products and
I have 2 models ( model1 and model2 ) that have a many to

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.