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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:36:36+00:00 2026-05-25T22:36:36+00:00

I have model as class Employer(models.Model): create_user = models.ForeignKey(User,unique=False,null=True, related_name=’%(class)s_user_create’) update_user = models.ForeignKey(User,unique=False,null=True, related_name=’%(class)s_user_update’)

  • 0

I have model as

class Employer(models.Model):
    create_user = models.ForeignKey(User,unique=False,null=True, related_name='%(class)s_user_create')
    update_user = models.ForeignKey(User,unique=False,null=True, related_name='%(class)s_user_update')

and I would like to list all Employer objects while I was at details of user in Django admin panel.

I have written something like

admin.py

class EmployerInline(admin.TabularInline):
    model = Employer

class UserAdmin(admin.ModelAdmin):
    inlines = [
               EmployerInline
    ]

admin.site.register(UserAdmin)

but it gives me error as 'MediaDefiningClass' object is not iterable

How can I list employers that are created by a spesific user while I was looking for user’s details ?

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-25T22:36:37+00:00Added an answer on May 25, 2026 at 10:36 pm

    The particular error you mention doesn’t seem to have anything to do with what’s going on in your code, so I’m not sure about that particularly. However, you have other errors here, so potentially fixing those will resolve that error as well.

    First, you need to specify fk_name on your EmployerInline. Django resolves the foreign key automatically in most circumstances, but since you have two foreign keys to the same model, you have to give Django some help.

    class EmployerInline(admin.TabularInline):
        model = Employer
        fk_name = 'create_user'
    

    Second, you may have just omitted it, but you must unregister User before registering it. You also need to specify the model when registering:

    admin.site.unregister(User)
    admin.site.register(User, UserAdmin)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a model class like this: class Note(models.Model): author = models.ForeignKey(User, related_name='notes') content
I have two models such that class Employer(models.Model): code = models.CharField(null=False,blank=False,default=) class JobTitle(models.Model): employer
I have a model: class Example(models.Model): unique_hash = models.CharField(max_length=32,unique=True) content = models.FileField(upload_to='source',blank=True,verbose_name=HTML Content File)
I have the following models class Person(models.Model): name = models.CharField(max_length=100) class Employee(Person): job =
I have two tables, one Company and one Employee: class Company(models.Model): name = models.CharField(max_length=60)
I have a following model: class Car(models.Model): make = models.CharField(max_length=40) mileage_limit = models.IntegerField() mileage
I have a model class Employee_Type(models.Model): def __unicode__(self): return self.name name = models.CharField(max_length=200, verbose_name=employee
I have two models for Publications and Employees: class Publication(models.Model): BOOK_CHAPTER = 1 ARTICLE
Assume I have a Model class called Bird and a instance of Bird called
Let's say I have a model class called Project, but instead of this: 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.