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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:31:57+00:00 2026-05-25T19:31:57+00:00

I am working on a django project in which I create a set of

  • 0

I am working on a django project in which I create a set of three abstract models that I will use for a variety of apps later on all of which will contain this hierarchy of three models. E.g.:

class Book(models.Models):
    name = models.CharField(...)
    author = models.CharField(...)
    ...

    objects = BookManager()

    class Meta:
        abstract = True

class Page(models.Models):
    content_type = models.ForeignKey(ContentType)
    object_id = models.PositiveIntegerField()
    content_object = generic.GenericForeignKey('content_type', 'object_id')
    chapter = models.CharField(...)
    ...

    objects = PageManager()

    class Meta:
        abstract = True

class Word(models.Models):
    content_type = models.ForeignKey(ContentType)
    object_id = models.PositiveIntegerField()
    content_object = generic.GenericForeignKey('content_type', 'object_id')
    line = models.IntegerField(...)
    ...

    objects = WordManager()

    class Meta:
        abstract = True

Besides these abstract classes, I want to provide customized Model Manager classes for each abstract class that will come in handy later on in the apps that inherit the managers

class BookManager(models.Manager):

    def computePrice(self, user, printJob):
        price = 0
        ...

class PageManager(models.Manager):

    def getPagesOfBook(self, book):
        return self.filter(content_type=book, object_id=book.id)
    ...

....

General question: Is this generally possible to create customized model managers for abstract classes and to use those in the models that inherit the abstract class?

The reason why I am asking is because I have not been able to implement this without receiving a hole set of exceptions every time I would run queries. I also tried a different way by running the queries in the abstract view (I also create an abstract view) though same exceptions occur.

If I am not mistaken, then part of the reason why this is not working is because abstract models cannot be queried. What I am asking is basically if there is a way how I can implement what I described above and if so, how that could be done.

Request Method: POST
Request URL:    http://127.0.0.1:8000/
Django Version: 1.3
Exception Type: AttributeError
Exception Value:    'Options' object has no attribute '_join_cache'
Exception Location: /usr/local/lib/python2.7/dist-packages/django/db/models/sql/query.py     in setup_joins, line 1267
Python Executable:  /usr/bin/python
Python Version: 2.7.1
  • 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-25T19:31:58+00:00Added an answer on May 25, 2026 at 7:31 pm

    Here is the information on custom managers and model inheritance: https://docs.djangoproject.com/en/dev/topics/db/managers/#custom-managers-and-model-inheritance

    General question: Is this generally possible to create customized model managers for abstract classes and to use those in the models that inherit the abstract class?

    Answer: Yes

    You are right that abstract base classes can’t be queried though. I’m not exactly sure what you’re doing (how Options looks, or how you’re querying it) but hopefully the general information will help

    Try this as an example

    class Encyclopedia(Book):
       pass
    

    And then query:

    > Encyclopedia.objects.computePrice(me, some_print_job)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a django project which will contain several apps. Each app
I'm working on a small django project that will be deployed in a servlet
I'm working on a django project that has a large fixture which does not
I have a django project that I have been working on as a solo
I have a project that I am working on in django. There are a
I need to have an at-home project now that I'm working on Python/Django at
I am working on a Silverlight project that uses Django on the server using
My Case: I'm working on a system that will need to create various X12
I have Django project on Dreamhost server which has several views that returns Json
I'm working on an intranet django project (not using GAE) for a company that

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.