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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:00:39+00:00 2026-06-17T10:00:39+00:00

I have few models in Django: from django.db import models class First(models.Model): first_name =

  • 0

I have few models in Django:

from django.db import models

class First(models.Model):
    first_name = models.CharField('First Name', max_length=100)
    first_value = models.IntegerField('Value')

    def __unicode__(self):
        return self.first_name 

class Second(models.Model):
    first_ref = models.ForeignKey(First)
    second_name = models.CharField('Second Name', max_length=100)
    second_value = models.IntegerField('Second Value')

    def __unicode__(self):
        return self.second_name

class Third(models.Model):
    second_ref = models.ForeignKey(Second)
    third_name = models.CharField('Third Name', max_length=100)
    third_value = models.IntegerField('Third Value')

    def __unicode__(self):
        return self.third_name

Now, when I try to add a new record for Third model in my Django admin, my <select> box is populated with second_name values. How can I display a concatenated string of different values from both ‘parent’ tables, e.g. first_name + first_value + second_name + second_value?

  • 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-17T10:00:41+00:00Added an answer on June 17, 2026 at 10:00 am

    Just update the unicode method of second Model:

    class Second(models.Model):
        first_ref = models.ForeignKey(First)
        second_name = models.CharField('Second Name', max_length=100)
        second_value = models.IntegerField('Second Value')
    
        def __unicode__(self):
            return '%s %s %s %s' % (
                self.first_ref.first_name, self.first_ref.first_value,
                self.second_name, self.second_value)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have few similar models in Django: class Material(models.Model): title = models.CharField(max_length=255) class Meta:
Please see the following Django models: - class Student(models.Model): reference_num = models.CharField(max_length=50, unique=True) name
So I have a few Django models that look like this: class City(models.Model): name
I have a simple Django model like: class Person(models.Model): referrer = models.ForeignKey('self', null=True) ...
I have been writing my first few Django models and wanted to take a
Given a set of typical models: # Application A from django.db import models class
I have set up a few models in a simple django project. When I
I have few models - User , Teacher and TeacherLeader . class User <
I have an admin model with a few inline models included with it (see
I am playing around with using Django and a few arduinos. From my models.py

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.