aaronvanderlip  committed fad5f7c

Renamed instance_manager to manager to keep with Django conventions

  • Participants
  • Parent commits 5b1a65a

Comments (0)

Files changed (2)

File autoslug/

             objects = models.Manager()
             title = models.CharField(max_length=200)
-            slug = AutoSlugField(populate_from='title', unique_with='pub_date__month', instance_manager=objects)
+            slug = AutoSlugField(populate_from='title', unique_with='pub_date__month', manager=objects)
         class NewsArticle(Article):
         # When using model inheritence, set manager to search for matching
         # slug values
-        self.instance_manager = kwargs.pop('instance_manager', None)
+        self.manager = kwargs.pop('manager', None)
         self.always_update = kwargs.pop('always_update', False)
         super(SlugField, self).__init__(*args, **kwargs)
         # get currently entered slug
         value = self.value_from_object(instance)
-        instance_manager = self.instance_manager
+        manager = self.manager
         # autopopulate
         if self.always_update or (self.populate_from and not value):
         # ensure the slug is unique (if required)
         if self.unique or self.unique_with:
-            slug = utils.generate_unique_slug(self, instance, slug, instance_manager)
+            slug = utils.generate_unique_slug(self, instance, slug, manager)
         assert slug, 'value is filled before saving'

File autoslug/

         attr = getattr(instance, field.populate_from)
         return callable(attr) and attr() or attr
-def generate_unique_slug(field, instance, slug, instance_manager):
+def generate_unique_slug(field, instance, slug, manager):
     Generates unique slug by adding a number to given value until no model
     instance can be found with such slug. If ``unique_with`` (a tuple of field
     index = 1
-    if not instance_manager:
-        instance_manager = type(instance).objects
+    if not manager:
+        manager = type(instance).objects
     # keep changing the slug until it is unique
     while True:
         # find instances with same slug
         lookups = dict(default_lookups, **{ slug})
-        rivals = instance_manager.filter(**lookups).exclude(
+        rivals = manager.filter(**lookups).exclude(
         if not rivals:
             # the slug is unique, no model uses it