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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:07:01+00:00 2026-06-13T17:07:01+00:00

models: class Detail(models.Model): def __unicode__(self): return self.title title = models.CharField(max_length=32) class Cars(models.Model): def __unicode__(self):

  • 0

models:

class Detail(models.Model):
    def __unicode__(self):
            return self.title
    title = models.CharField(max_length=32)

class Cars(models.Model):
    def __unicode__(self):
            return self.name
    name = models.CharField(max_length=32, unique=True)
    details = models.ManyToManyField(Detail)

So, every car has a many details – wheels, engine, etc. How to do this: in Django Admin situated Cars menu, in that menu we have a many lines of details (like in tutorial).
In admin I use:

class DetailInline(admin.TabularInline):
    model = Detail
    extra = 6
class CarsAdmin(admin.ModelAdmin):
    inlines = [DetailInline]

But it has error: Detail has no ForeignKey to Cars. How to fix it?

  • 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-13T17:07:02+00:00Added an answer on June 13, 2026 at 5:07 pm

    Django does not natively let you add a reverse inline.
    i.e. You can have the Detail page contain an inline admin of all the Cars that contain a ForeignKey to that particular Detail. However, the reverse is not natively possible.

    There is a workaround though wherein you have to override the admin template a bit. There is a previous SO question about this here: Inline-like solution for Django Admin where Admin contains ForeignKey to other model

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

Sidebar

Related Questions

Example models: class Parent(models.Model): name = models.CharField() def __unicode__(self): return self.name class Child(models.Model): parent
Given the following models: class Post(models.Model): title = models.CharField(max_length=200) html = models.TextField() class PostTag(models.Model):
Using Django 1.1.1 In models.py: class Site(models.Model): name = models.CharField(max_length=50) class SiteMonth(models.Model): site =
I have two models: class Product(models.Model): name = models.CharField(max_length=255) class ProductPhoto(models.Model): product = models.ForeignKey('Product',
Say I have the good old person/group/membership relationship class Person(models.Model): name = models.CharField(max_length=128) def
I have two basic models, Story and Category: class Category(models.Model): title = models.CharField(max_length=50) slug
I have a model that is something like this: class Input(models.Model): details = models.CharField(max_length=1000)
/mysite/project4 class notes(models.Model): created_by = models.ForeignKey(User) detail = models.ForeignKey(Details) Details and User are in
I have the following models: class ProjectUser(models.Model): categories = models.ManyToManyField('UserCategory', blank=True, null=True) user_id =
A Event class in models.py class Event(models.Model): timestamp = models.DateTimeField() message = models.TextField() def

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.