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.
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.
Subreddit
Post Details
- Posted
- 5 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/django/comm...