from app_data import AppDataField
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import python_2_unicode_compatible


@python_2_unicode_compatible
class AppHookConfig(models.Model):
    """
    This is the generic (abstract) model that holds the configurations for each AppHookConfig
    concrete model
    """
    type = models.CharField(max_length=100)
    namespace = models.CharField(max_length=100)
    app_data = AppDataField()

    class Meta:
        verbose_name = _(u'app-hook config')
        verbose_name_plural = _(u'app-hook configs')
        unique_together = ('type', 'namespace')
        abstract = True

    def save(self, *args, **kwargs):
        self.type = '%s.%s' % (
            self.__class__.__module__, self.__class__.__name__)
        super(AppHookConfig, self).save(*args, **kwargs)

    def __str__(self):
        return _(u'%s / %s') % (self.type, self.namespace)
from app_data import AppDataField
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import python_2_unicode_compatible


@python_2_unicode_compatible
class AppHookConfig(models.Model):
    """
    This is the generic (abstract) model that holds the configurations for each AppHookConfig
    concrete model
    """
    type = models.CharField(max_length=100)
    namespace = models.CharField(max_length=100)
    app_data = AppDataField()

    cmsapp = None

    class Meta:
        verbose_name = _(u'app-hook config')
        verbose_name_plural = _(u'app-hook configs')
        unique_together = ('type', 'namespace')
        abstract = True

    def save(self, *args, **kwargs):
        self.type = '%s.%s' % (
            self.__class__.__module__, self.__class__.__name__)
        super(AppHookConfig, self).save(*args, **kwargs)

    def __str__(self):
        if self.cmsapp:
            return _(u'%s / %s') % (self.cmsapp.name, self.namespace)
        else:
            return _(u'%s / %s') % (self.type, self.namespace)
Change the str representation of AppHookConfig by using the related CMSApp name instead of the type
Change the str representation of AppHookConfig by using the related CMSApp name instead of the type

  from app_data import AppDataField
  from django.db import models
  from django.utils.translation import ugettext_lazy as _
  from django.utils.encoding import python_2_unicode_compatible
  
  
  @python_2_unicode_compatible
  class AppHookConfig(models.Model):
      """
      This is the generic (abstract) model that holds the configurations for each AppHookConfig
      concrete model
      """
      type = models.CharField(max_length=100)
      namespace = models.CharField(max_length=100)
      app_data = AppDataField()
  
+     cmsapp = None
+ 
      class Meta:
          verbose_name = _(u'app-hook config')
          verbose_name_plural = _(u'app-hook configs')
          unique_together = ('type', 'namespace')
          abstract = True
  
      def save(self, *args, **kwargs):
          self.type = '%s.%s' % (
              self.__class__.__module__, self.__class__.__name__)
          super(AppHookConfig, self).save(*args, **kwargs)
  
      def __str__(self):
+         if self.cmsapp:
+             return _(u'%s / %s') % (self.cmsapp.name, self.namespace)
+         else:
-         return _(u'%s / %s') % (self.type, self.namespace)
+             return _(u'%s / %s') % (self.type, self.namespace)
Change the str representation of AppHookConfig by using the related CMSApp name instead of the type
## Code Before:
from app_data import AppDataField
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import python_2_unicode_compatible


@python_2_unicode_compatible
class AppHookConfig(models.Model):
    """
    This is the generic (abstract) model that holds the configurations for each AppHookConfig
    concrete model
    """
    type = models.CharField(max_length=100)
    namespace = models.CharField(max_length=100)
    app_data = AppDataField()

    class Meta:
        verbose_name = _(u'app-hook config')
        verbose_name_plural = _(u'app-hook configs')
        unique_together = ('type', 'namespace')
        abstract = True

    def save(self, *args, **kwargs):
        self.type = '%s.%s' % (
            self.__class__.__module__, self.__class__.__name__)
        super(AppHookConfig, self).save(*args, **kwargs)

    def __str__(self):
        return _(u'%s / %s') % (self.type, self.namespace)
## Instruction:
Change the str representation of AppHookConfig by using the related CMSApp name instead of the type
## Code After:
from app_data import AppDataField
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import python_2_unicode_compatible


@python_2_unicode_compatible
class AppHookConfig(models.Model):
    """
    This is the generic (abstract) model that holds the configurations for each AppHookConfig
    concrete model
    """
    type = models.CharField(max_length=100)
    namespace = models.CharField(max_length=100)
    app_data = AppDataField()

    cmsapp = None

    class Meta:
        verbose_name = _(u'app-hook config')
        verbose_name_plural = _(u'app-hook configs')
        unique_together = ('type', 'namespace')
        abstract = True

    def save(self, *args, **kwargs):
        self.type = '%s.%s' % (
            self.__class__.__module__, self.__class__.__name__)
        super(AppHookConfig, self).save(*args, **kwargs)

    def __str__(self):
        if self.cmsapp:
            return _(u'%s / %s') % (self.cmsapp.name, self.namespace)
        else:
            return _(u'%s / %s') % (self.type, self.namespace)