django_extensions and AutoSlugField

307 views
Skip to first unread message

Dan Jewett

unread,
Jan 19, 2009, 11:03:43 AM1/19/09
to Django users
Maybe I'm just implementing this incorrectly, but if anyone is using
this extension maybe you could shed some light on this error.

When I try to add or save my Model I get:
AttributeError: 'str' object has no attribute 'creation_counter'

Here's what I think is relevant.
in models.py: (partial)
from django_extensions.db.fields import AutoSlugField

class Album(models.Model):
title = models.CharField(max_length=250)
slug = AutoSlugField(populate_from=title, max_length=250,
editable=True)
# slug = models.SlugField(max_length=250)

in admin.py: (partial)

class AlbumOptions(admin.ModelAdmin):
prepopulated_fields = {'slug': ('title',)}

On Album Add or Save, I get the error.

<snip>
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/
site-packages/django_extensions/db/fields/__init__.py" in pre_save
108. value = unicode(self.create_slug(model_instance, add))
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/
site-packages/django_extensions/db/fields/__init__.py" in create_slug
63. populate_field = model_instance._meta.get_field
(self._populate_from)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/
site-packages/django/db/models/options.py" in get_field
260. if f.name == name:
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/
site-packages/django/db/models/fields/__init__.py" in __cmp__
102. return cmp(self.creation_counter,
other.creation_counter)

Exception Type: AttributeError at /admin/fc/album/1/
Exception Value: 'str' object has no attribute 'creation_counter'

Local vars:
other 'id'
self <django.db.models.fields.CharField object at 0x1182850>

Thanks for any suggestions.
Dan J.

Dan Jewett

unread,
Jan 19, 2009, 11:58:55 AM1/19/09
to Django users
Found it. populate_from wants a string.
Reply all
Reply to author
Forward
0 new messages