python - Slug field error in django -


i trying integrate following blog app site,i following error slug field ,how resolve issue

     typeerror @ /login/       __init__() got unexpected keyword argument 'prepopulate_from'       request method:        request url:   http://192.168.254.35/accounts/login/new_wind/      django version:   1.2.1 svn-1957      exception type:   typeerror      exception value:       __init__() got unexpected keyword argument 'prepopulate_from' 

this models.py

from django.db import models datetime import datetime  class blogpost(models.model):   title = models.charfield(max_length=128)   slug = models.slugfield(prepopulate_from=('title',))   body = models.textfield()   published = models.booleanfield(default=true)   date_posted = models.datetimefield(default=datetime.now)  def __unicode__(self):     return self.title  class admin:     pass 

the error says all: slugfield not take keyword argument prepopulate_from. the docs - takes argument max_length in addition standard argument. should done in admin class instead.

edit: model file be:

from django.db import models datetime import datetime  class blogpost(models.model):   title = models.charfield(max_length=128)   slug = models.slugfield()   body = models.textfield()   published = models.booleanfield(default=true)   date_posted = models.datetimefield(default=datetime.now)  def __unicode__(self):     return self.title 

and admin.py file same application be:

from django.contrib import admin myapp.models import blogpost  class blogpostadmin(admin.modeladmin):     prepopulated_fields = {"slug": ("title",)}  admin.site.register(blogpost, blogpostadmin) 

if don't understand how admin site works, see part 2 of official django tutorial.


Comments