# Path: shrubbery/db/utils.py
# def no_related_name(hidden=False):
#     no_related_name._next += 1
#     name = "_no_related_name_%%(class)s_%s" % (no_related_name._next)
#     if hidden:
#         name += '+'
#     return name


from django.db import models as django_models
from shrubbery.db.utils import no_related_name
    from south.modelsinspector import add_introspection_rules
            cls = class_decorator(cls)
        return cls(
            model=model,
            core_filters={'%s__pk' % self.query_name(): instance.pk},
            instance=instance,
            symmetrical=False,
            source_field_name=self.source_field_name(),
            target_field_name=self.target_field_name()
        )

    def __set__(self, instance, value):
        if instance is None:
            raise AttributeError, "Manager must be accessed via instance"

        manager = self.__get__(instance)
        if hasattr(manager, 'assign'):
            manager.assign(value)
        else:
            manager.clear()
            manager.add(*value)


class ManyToManyField(django_models.ManyToManyField):
    def __init__(self, *args, **kwargs):
        self.manager_class = kwargs.pop('manager_class', None)
        self.manager_class_decorator = kwargs.pop('manager_class_decorator', None)
        self.related_manager_class = kwargs.pop('related_manager_class', None)
        self.related_manager_class_decorator = kwargs.pop('related_manager_class_decorator', None)

        if 'related_name' in kwargs and not kwargs['related_name']:

# Path: shrubbery/db/utils.py
# def no_related_name(hidden=False):
#     no_related_name._next += 1
#     name = "_no_related_name_%%(class)s_%s" % (no_related_name._next)
#     if hidden:
#         name += '+'
#     return name


# Path: shrubbery/db/extensions/rel_fields.py
from django.db import models as django_models
from shrubbery.db.utils import no_related_name
    from south.modelsinspector import add_introspection_rules

            cls = class_decorator(cls)
        return cls(
            model=model,
            core_filters={'%s__pk' % self.query_name(): instance.pk},
            instance=instance,
            symmetrical=False,
            source_field_name=self.source_field_name(),
            target_field_name=self.target_field_name()
        )

    def __set__(self, instance, value):
        if instance is None:
            raise AttributeError, "Manager must be accessed via instance"

        manager = self.__get__(instance)
        if hasattr(manager, 'assign'):
            manager.assign(value)
        else:
            manager.clear()
            manager.add(*value)


class ManyToManyField(django_models.ManyToManyField):
    def __init__(self, *args, **kwargs):
        self.manager_class = kwargs.pop('manager_class', None)
        self.manager_class_decorator = kwargs.pop('manager_class_decorator', None)
        self.related_manager_class = kwargs.pop('related_manager_class', None)
        self.related_manager_class_decorator = kwargs.pop('related_manager_class_decorator', None)

        if 'related_name' in kwargs and not kwargs['related_name']:

            kwargs['related_name'] = no_related_name()