[Answer]-How can I get the name of app inside a model?

1👍

✅

You should use Model._meta.app_label

Plus: If you’re creating a mixin you don’t need to extend it from models.Model and make it abstract. You can create a regular class:

class EditLinkMixin(object):
    def get_admin_link(self):
        return '/admin/%s/%s/%d/' % (self._meta.app_name, self.__class__.__name__, self.pk)

class MyModel(models.Model, EditLinkMixin):
    pass

Leave a comment