Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

0
Is this expected behaviour for abstract models?
Post Body

Just noticed this happen and I found it strange. I have two models that should be comprised entirely of abstract ancestors. Something like this:

class CoreEntry(models.Model):
    title = models.CharField(...)
    slug = models.SlugField(...)

    class Meta:
        abstract = True

class ContentEntry(models.Model):
    content = models.TextField(...)

    class Meta:
        abstract = True

class ExcerptEntry(models.Model):
    excerpt = models.TextField(...)

    class Meta:
        abstract = True

# a few more abstract models here, then the actual models I'm using

class Post(CoreEntry, ContentEntry, ExcerptEntry, ...):
    pass

class Page(CoreEntry, ContentEntry, ExcerptEntry, ...):
    pass

Nothing weird so far. However, I just realized that I forgot to make ExcerptEntry an abstract base class. So Django created a separate table and a foreign key from Post and Page pointing to ExcerptEntry (which is to be expected).

The weird thing is that Django never created an ID field on Page and Post. Instead it used the FK to the ExcerptEntry as the Primary Key field.

There's probably a reason Django behaves this way but I'm not really sure I get it.

Author
Account Strength
60%
Account Age
11 years
Verified Email
No
Verified Flair
No
Total Karma
578
Link Karma
339
Comment Karma
239
Profile updated: 3 days ago
Posts updated: 6 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
5 years ago