I am using Django 3.2
I have written a standalone app social
that has models defined like this:
from abc import abstractmethod
class ActionableModel:
# This MUST be implemented by ALL CONCRETE sub classes
@abstractmethod
def get_actionable_object(self):
pass
# This MUST be implemented by ALL CONCRETE sub classes
@abstractmethod
def get_owner(self):
pass
def get_content_info(self):
actionable_object = self.get_actionable_object()
ct = ContentType.objects.get_for_model(actionable_object)
object_id = actionable_object.id
return (ct, object_id)
# ...
class Likeable(models.Model, ActionableModel):
likes = GenericRelation(Like)
likes_count = models.PositiveIntegerField(default=0, db_index=True)
last_liked = models.DateTimeField(editable=False, blank=True, null=True, default=None)
# ...
in my project (that uses the standalone app), I have the following code:
myproject/userprofile/apps.py
class UserprofileConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'userprofile'
verbose_name = _('User Profile')
def ready(self):
# Check if social app is installed
from django.apps import apps
if apps.is_installed("social"):
# check some condition
# inherit from social.Likeable
# ... ?
How can I dynamically get my model userprofile.models.UserAccount
to derive from Likeable?