from __future__ import absolute_import, unicode_literals

from django.apps import apps as django_apps

from .signals import connect

__version__ = '0.0.1'
default_app_config = 'diffs.apps.DiffLogConfig'

klasses_to_connect = []


def register(klass):
    """
    Decorator function that registers a class to record diffs.

    @register
    class ExampleModel(models.Model):
        ...
    """
    from .models import DiffLogEntryManager
    from dirtyfields import DirtyFieldsMixin
    # Hack to add dirtyfieldsmixin automatically
    if DirtyFieldsMixin not in klass.__bases__:
        klass.__bases__ = (DirtyFieldsMixin,) + klass.__bases__

    klass.add_to_class('diffs', DiffLogEntryManager())

    if not django_apps.ready:
        klasses_to_connect.append(klass)
    else:
        connect(klass)

    return klass


@@ -55,53 +55,8 @@
 ls%0A%0A
-from django.apps import apps as django_apps%0A%0A
 from
@@ -356,42 +356,46 @@
 rom 
-.models import DiffLogEntryManager
+django.apps import apps as django_apps
 %0A   
@@ -435,16 +435,61 @@
 ldsMixin
+%0A%0A    from .models import DiffLogEntryManager
 %0A    # H

Reorganize imports to be later