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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:09:19+00:00 2026-05-17T20:09:19+00:00

I dam trying to do this: http://docs.djangoproject.com/en/dev/topics/db/models/#be-careful-with-related-name Using this style This is saved as

  • 0

I dam trying to do this:
http://docs.djangoproject.com/en/dev/topics/db/models/#be-careful-with-related-name

Using this style

This is saved as common/abstract.py

class OtherModel(models.Model):

   something = Charfield(max_length=100)

   class Meta:
            abstract = True

class Base(models.Model):
        fk_model = models.ForeignKey(OtherModel, related_name="%(app_label)s_%(class)s_related")

        class Meta:
            abstract = True

Then I import it into another file. Let’s call this app/models.py

from common.abstract import Base

class ChildB(Base):
    pass

I have installed ‘app’ but not the ‘common’. It will import nicely without the FK or M2M relationship, but when I try to add it, I get this error:

/lib/python2.6/site-packages/django/db/models/fields/related.py”, line 808, in init
assert not to.meta.abstract, “%s cannot define a relation with abstract class %s” % (self.class._name__, to._meta.object_name)
AssertionError: ForeignKey cannot define a relation with abstract class OtherModel

Please advise…. also let me know if you have any questions or don’t understand something that I am explaining. The file that I working with is really complex, so I didn’t want to post the whole thing since I knew that it is breaking on this one relationship.

  • 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-17T20:09:19+00:00Added an answer on May 17, 2026 at 8:09 pm

    I figured out the problem…..

    This will work:

    from django.db import models
    
    class CommonInfo(models.Model):
    
        name = models.CharField(max_length=100)
    
    class Base(models.Model):
        m2m = models.ForeignKey(CommonInfo, related_name="%(app_label)s_%(class)s_related")
    
        class Meta:
            abstract = True
    
    class ChildA(Base):
        pass
    

    This will give you the error: AssertionError: ForeignKey cannot define a relation with abstract class OtherModel.This is because you can’t have a FK relationship or M2M relationship on an abstract pointing to ANOTHER abstract class.

    from django.db import models
    
    class CommonInfo(models.Model):
        class Meta:
            abstract = True
    
        name = models.CharField(max_length=100)
    
    class Base(models.Model):
        m2m = models.ForeignKey(CommonInfo, related_name="%(app_label)s_%(class)s_related")
    
        class Meta:
            abstract = True
    
    class ChildA(Base):
        pass
    

    This is sad news for me. Sad news indeed. I hope my sad news benefits someone else.

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

Sidebar

Related Questions

FLV format specification is here: http://www.adobe.com/content/dam/Adobe/en/devnet/flv/pdfs/video_file_format_spec_v10.pdf 1) FLV body consists of tags 2) Each
I'm mapping a array with this code: url = http://www.cnn.com page = Mechanize.new.get(url) images_url
Using the asp.net file upload control is very easy, i'm trying to squeeze it
I load in a div with class name .preview image's gallery like this: <img
I'm trying to construct a little mobile optimized web. This web list a set
I am using the DAM module. Does indexed search index the meta data from
I just translated this program, #include <stdio.h> int dam[1000][1000]; int main (int argc, const
Users upload different types of files (images, videos, audio, docs etc) on our DAM
Trying to use make from cygwin using g++ I was getting Access Denied error
This is the data file: ID YR MO DA YrM MoM DaM 100 2010

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.