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

The Archive Base Latest Questions

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

Hi fellow django users, How can I add a field from a related object

  • 0

Hi fellow django users,

How can I add a field from a related object in the list_editable admin property?

# models.py
class Order(Model):
    reference = CharField(max_length=25)

class Product(Model):
    name = CharField(max_length=50)
    order = ForeignKey(Order)

# admin.py
class ProductAdmin:
    list_display = ('name', 'order_reference')
    list_editable = ('name', 'order__reference') # <--- THIS !

    def order_reference(self, obj):
        return obj.order.reference

I tried it this way, but it won’t work. I also tried to add a property in the Product class, but nope, it won’t work either. Any clue?

Thanks.

  • 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:36:01+00:00Added an answer on May 27, 2026 at 7:36 am

    From the documentation:

    list_editable interacts with a couple of other options in particular
    ways; you should note the following rules:

    1. Any field in list_editable must also be in list_display. You can’t edit a field that’s not displayed!
    2. The same field can’t be listed in both list_editable and list_display_links — a field can’t be both a form and a link.
    3. You’ll get a validation error if either of these rules are broken.

    Notice that you use *order_reference* and *order__reference* in list_display and list_editable, respectively. So in short, I don’t think you can do this easily. If you want to have inspiration, you could check out the implementation of pageadmin.py in django-cms, but it’s NOT straightforward!!

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

Sidebar

Related Questions

I'm trying to follow the code from the django docs: class Person(models.Model): name =
I follow the description on the http://docs.djangoproject.com/en/1.2/ref/contrib/sitemaps/ I from django.contrib import sitemaps add this
This is a follow-up question on Delete field from standard Django model . In
My fellow programmers did not think to add timestamps to every tables of our
I am considering using django-cms to implement the following scenario: Admins can create hierarchical
Hi fellow Djangonauts: I checked my project with django-lint , and it yields: W:211,16:MyModel:
There is a Django view that loads Member objects from the database with a
I read from http://www.packtpub.com/article/friends-via-email-social-web-application-django-1.0 and follow the steps: => And change my setting.py SITE_HOST
Using Django 1.3 with PostgreSQL 9.0, I have a multi-step object creation function/view, where:
I have the following models: class Post(models.Model): message = models.TextField() (etc.) class UserProfile(models.Model): user

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.