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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:44:55+00:00 2026-06-04T16:44:55+00:00

I’m pulling my hair out trying to solve this (hopefully) simple problem. I am

  • 0

I’m pulling my hair out trying to solve this (hopefully) simple problem.

I am using Django-nonrel, and I am trying to setup a few models. I’ve simplified the code below:

class Application(models.Model)
    name = "Application"

    def get_name(self):
        print(self.name)

class ExampleApp(Application)
    name = "Example Application"

class Site(models.Model)
    app = models.OneToOneField(Application, null=True)
    id  = models.CharField(max_length=1)
    # other details not important

When I obtain an instance of Site, I would like to obtain an instance of the derived class (e.g. ExampleApp)

class MyView(View):
    def get(self, request, *args, **kwargs):
        # Presuppose that I have an object with id="a"
        site = Site.objects.filter(id="a")

        #<Application: Application>
        app = site.app

        #returns "Application", not "Example Application"
        app.get_name()

How can I access the derived class?

(Ideally, I would like Application to be an abstract base class, but django does not allow relationships to abstract base classes. I would define fields inside Application, but django-nonrel does not support multi-table inheritance.)

  • 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-04T16:44:56+00:00Added an answer on June 4, 2026 at 4:44 pm

    What Furbeenator answered is correct, but I feel that my (self-)answer could be more valuable to anyone in my situation.

    Django-nonrel includes a few nice apps, notable djangotoolbox. Included in djangotoolbox is a particular field, EmbeddedModelField. It appears to store a copy of a model as a blob in the ‘container’ model.

    In my example:

    from djangotoolbox.fields import EmbeddedModelField
    
    class Site(models.Model)
        app = EmbeddedModelField(null=True)
        id  = models.CharField(max_length=1)
        # other details not important
    

    The upside to this is that, in my circumstances, it also meant that I could make my Application class abstract. The downside is that the data is now duplicated, and I still cannot access the Site instance from the Application instance (but in my case, that was an acceptable tradeoff).

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has

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.