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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:40:49+00:00 2026-06-09T01:40:49+00:00

I have a Django model which can have many generic relationships. This is achieved

  • 0

I have a Django model which can have many generic relationships. This is achieved by manually creating a junction model:

class ContentProjectContentItem(models.Model):
    content_project = models.ForeignKey('ContentProject')

    # Generic relations via Content Type Framework
    object_id = models.PositiveIntegerField()
    content_type = models.ForeignKey(ContentType)
    item = generic.GenericForeignKey('content_type', 'object_id') 

    class Meta:
        unique_together = ('content_project', 'object_id', 'content_type')
        app_label = "cms"

That is related to the parent model via a ManyToManyField:

class ContentProject(models.Model):
    title = models.CharField(max_length=100)
    date_created = models.DateTimeField(auto_now_add=True)

    # Related content (Assets, Resources, Media, etc)
    content_items = models.ManyToManyField(ContentProjectContentItem)

I’m still developing my skills using the Django admin, so I’m unsure of how to create an inline that will allow me to add multiple ContentProjectContentItems to a ContentProject. I have tried using generic.GenericStackedInline, but to no avail:

class ContentItemInline(generic.GenericStackedInline):
    name = "content_project"
    model = ContentProjectContentItem 

class ContentProjectAdmin(MPTTModelAdmin):
    list_display = ('title' , 'date_created')
    search_fields = ('title' , 'date_created')

    inlines = [
        ContentItemInline,
    ]

I am simply seeing the standard ManyToMany multi-select for content_items (which is what I would expect). I am unsure of how to make ContentProjectAdmin aware of the junction table’s generic relationships. Any thoughts?

  • 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-09T01:40:54+00:00Added an answer on June 9, 2026 at 1:40 am

    I ended up implementing a custom change_view template to manually add form elements, and overrides for the form save method to handle this use case.

    Not the prettiest solution, but effective nonetheless.

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

Sidebar

Related Questions

I have a Django model like this: class Registration(models.Model): appId =models.CharField(max_length = 100) registeredUser
I have django model which consist of parent child relationship filed I want to
I have a Django model which has a foreign key that is optional. I
I want a Django model to have a date field in which the year,
If I have a Django model with a FileField e.g., class Probe(models.Model): name =
I have a basic Django model like: class Business(models.Model): name = models.CharField(max_length=200, unique=True) email
I have a Django model that defines a TimeSlot. Each TimeSlot can hold a
Greetings, I have these 2 models: from django.db import models class Office(models.Model): name =
I'm currently developing a Django site in which users can have multiple 'accounts', so
I have created a model which has foreign key to the django.contrib.auth.models User model.

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.