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

  • Home
  • SEARCH
  • 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 6026277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:25:20+00:00 2026-05-23T04:25:20+00:00

I have these models: class App(models.Model): name = models.CharField(max_length=100) class ProjectA(models.Model): name = models.CharField(max_length=100)

  • 0

I have these models:

class App(models.Model):
  name = models.CharField(max_length=100)

class ProjectA(models.Model):
  name = models.CharField(max_length=100)
  app  = models.ForeignKey(App)

class ProjectB(ProjectA):
  pass

class Attachment(models.Model):
  content_type    = models.ForeignKey(ContentType)
  object_id       = models.PositiveIntegerField()
  project         = generic.GenericForeignKey("content_type","object_id")
  file            = models.FileField(upload_to=".")

I’m registering all the models for the admin, and I’m unregistering Group, User and Site. The thing is, when I access the Attachment in the admin, I see it rendered like this:

admin for attachment

In the Content type select, I see this list:

select

The reason Attachment has a GenericForeignKey is because both ProjectA and ProjectB need to access it. I know that ProjectA and ProjectB are identical, but it’s a requirement that they are stored in 2 separate tables. How could I made the Attachment class useable from the admin? I know how to use contenttypes from normal views, but from the admin not.

In the Attachment class I would only like to have a select for Project A or Project B, and then a list of all Project A’s or all Project B’s, followed by the file that I want to attach.

Is such a thing possible from the Admin? Will I need to show the user the Object Id column?

  • 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-23T04:25:20+00:00Added an answer on May 23, 2026 at 4:25 am

    if I’m not wrong, you want this. http://code.google.com/p/django-genericadmin/

    my advice will work differently. you will add a little more form in ProjectA, ProjectB as inline. in your admin.py

    from django.contrib import admin
    from django.contrib.contenttypes import generic
    
    from myproject.myapp.models import Attachment, ProjectA, ProjectB
    
    class Attachmentline(generic.GenericTabularInline): #or generic.GenericStackedInline, this has different visual layout.
        model = Attachment
    
    class ProjectAdmin(admin.ModelAdmin):
        inlines = [
            Attachmentline,
        ]
    
    admin.site.register(ProjectA, ProjectAdmin)
    admin.site.register(ProjectB, ProjectAdmin)
    

    go your ProjectA or ProjectB admin and see new admin.

    this isn’t what you want but it can help you. otherwise you need check first link.

    • 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 Review(models.Model): name = models.CharField(max_length = 50) link = models.CharField(max_length
I have a basic model: class Person(models.Model): first_name = models.CharField(max_length=50) last_name = models.CharField(max_length=50) state
I have the following structure: class FeatureType(models.Model): type = models.CharField(max_length=20) def __unicode__(self): return self.type
I have some model objects I'm using in my Java client application. Later these
I have a rails model that validates uniqueness of 2 form values. If these
I have these tables: customer -------- customer_id int name varchar(255) order ----- order_id int
Imagine I have these python lists: keys = ['name', 'age'] values = ['Monty', 42,
I wold like to have in my model a CharField with fixed length. In
Django-admin is pluralizing a model that I have running as a proxy class. The
I have a simple Android OpenGL-ES app, and as all the models are very

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.