Unfortunately, after countless attempts, I haven't found any promising way to solution.
I'm searching for the least intrusive way to customize the flatpages used by django-oscar's 'dashboard.pages' app. It would be ok to break the migration history of the django app and manage them manually.
Is it possible to solve it using the get_model loader from oscar and how? (I don't need a full solution and am thankful for every hint)
Additional information:
My intention is to create a FlatPageCategory model
from oscar.core.utils import slugify
class FlatPageCategory(models.Model):
name = models.CharField(max_length=255, db_index=True)
url = models.SlugField()
and add a few fields to FlatPage model
from django.contrib.flatpages.models import FlatPage
class FlatPage(FlatPage):
display_order = models.SmallIntegerField(
default=0,
)
category = models.ForeignKey(
'FlatPageCategory',
on_delete=models.SET_NULL,
blank=True, null=True,
)
attachments = models.ManyToManyField(
File,
)
def get_absolute_url(self):
""" Prepend category url if category exists. """
url = super().get_absolute_url()
if self.category:
return f'{self.category.url}/{url}'
return url
After trying different approaches this was my solution: Creating OneToOne-Relationship from a custom page model to FlatPage and a ForeignKey from Attachment to FlatPage.
You can find the source of this implementation in the GitHub-Project.
It is not really the solution I wanted and asked in the question and therefore I think the question should stay open.