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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:01:07+00:00 2026-05-20T11:01:07+00:00

after wracking my brain for days, I just hope someone can point me to

  • 0

after wracking my brain for days, I just hope someone can point me to the right approach.
I have 4 Models: Page, Element, Style and Post.

Here is my simplyfied models.py/admin.py excerpt: http://pastebin.com/uSHrG0p2

In 2 sentences:

A Element references 1 Style and 1 Post (2 FKs).

A Page can reference many Elements, Elements can be referenced by many pages (M2M).

On the admin site for Page instances I included the M2M relation as ‘inline’. So that I have multiple rows to select Element-instances.
One row looking like: [My Post A with My Style X][V]

What I want is to replace that one dropdown with 2 dropdowns. One with all instances of Post and one with all instances of Style (creating Element instances in-place). So that one row would look similar to the Element admin site: [My Post A][V] [My Style X][V]

Sounds easy, but I’m just completely lost after reading and experimenting for 2 days with ModelForms, ModelAdmins, Formsets, … .
Can I do that without custom views/forms within the Django admin functionality?

One of my approaches was to access the Post/Style instances from a PageAdminForm like this, trying to create a form widget manually from it… but failed to do so:

p = Page.objects.get(pk=1)
f = PageAdminForm(instance=p)
f.base_fields['elements'].choices.queryset[0].post

Any advice or hint which way I need to go?
Thank you for your time!

  • 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-20T11:01:07+00:00Added an answer on May 20, 2026 at 11:01 am

    I got exactly what I wanted after removing the M2M field and linking Elements to a Page with a 3rd ForeignKey in Element:

    class Element(models.Model):
        page = models.ForeignKey(Page)        
        post = models.ForeignKey(Post)
        style = models.ForeignKey(Style)
    

    Actually a non-M2M link makes more sense for my application after all.

    Memo to self: Rethink model relations before trying to outsmart Django 🙁

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

Sidebar

Related Questions

After doing setting page.clipRect followed by page.render , how can you disable clipRect so
After deploying WCF server (svc) on my Server, I have got this message when
After the header I have one div which contains two others, which are next
after i have add 6 or more tabbar on the InterfaceBuilder it will automatically
After thinking for long, I have decided to build my data app for the
After seeing the 13th Floor back in the day I have been obsessed to
After answering this question I put together the following C# code just for fun:
After wasting two days with this question (and trying to make it work), I've
I was just wondering at what point the browser executes JavaScript when it comes
After setting up the following protocol, I have noticed that I am getting a

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.