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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:36:04+00:00 2026-05-26T01:36:04+00:00

I have the following in admin.py class AdInline(admin.StackedInline): model = Ad class UnitAdmin(admin.ModelAdmin): fields

  • 0

I have the following in admin.py

class AdInline(admin.StackedInline):
    model = Ad

class UnitAdmin(admin.ModelAdmin):
    fields = ('user', 'name', 'about', 'url', 'active', 'type')
    list_display = ('user', 'name', 'url', 'created', 'active', 'type')

    inlines = [AdInline]

class AdAdmin(admin.ModelAdmin):
    fields = ('user', 'title', 'about', 'url', 'active')
    list_display = ('user', 'title', 'url', 'created', 'active', 'clicks')

Now this is done in mongodb so i don’t want relationships.. but I want admin to work.. When I try to load up a unit I get the following error

Exception Value:    <class 'ad.models.Ad'> has no ForeignKey to <class 'ad.models.Unit'>

Ad has no foreign key what so ever. I want all the ads to live inside a unit as a dictionary in mongodb. I just want to leverage the power of django admin’s to create them.

any pointers?

  • 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-26T01:36:05+00:00Added an answer on May 26, 2026 at 1:36 am

    Your inline has to have a foreign key to the model you want to include it in, i.e. your Ad needs a foreign key to your unit; that’s the way it works. If you can’t represent that relationship, then you can’t use inlines. I’m not sure what can replicate this behaviour in the admin, but I don’t think inlines fit the bill.

    https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.InlineModelAdmin

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

Sidebar

Related Questions

I have the following Django model: class opetest(models.Model): name = models.CharField(max_length=200) people = models.ManyToManyField(User,
I have the following models: class Application(models.Model): users = models.ManyToManyField(User, through='Permission') folder = models.ForeignKey(Folder)
I have the following model set up: class UserProfile(models.Model): Additional attributes for users. url
I have the following models: class Category(models.Model): name = models.CharField(max_length=40) class Item(models.Model): name =
I have the following defined: class AnswerChoiceInline(admin.TabularInline): model = AnswerChoice # extra = 0
I have the following: from django.contrib.auth.models import User class ClientDetails(models.Model): created_by = models.ForeignKey(User) ...
I have the following model: from django.db import models class State(models.Model): name = models.CharField(max_length=30)
In my Django App I have the following model: class SuperCategory(models.Model): name = models.CharField(max_length=100,)
I have the following models: class Author(db.Model): name = db.StringProperty() class Story(db.Model): author =
I have the following model and TabularInline subclasses: class SomeModel(models.Model): name = models.CharField(max_length=50) 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.