2013-01-23 24 views
5

Hey私はPractical Django Projectsの本を使っています。私はSlugFieldをあらかじめ準備しようとしていますが、それは起こっていません。Django 'prepopulated_fields' not working

#models.py 
from django.db import models 

class Category (models.Model): 
    title = models.CharField(max_length=250) 
    slug = models.SlugField (unique=True) 
    description = models.TextField() 

    class Meta: 
     verbose_name_plural = "Categories" 

    def __unicode__(self): 
     return self.title 
#admin.py 
from django.contrib import admin 
from coltrane.models import Category 

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

admin.site.register(Category) 

答えて

12

変更admin.site.register(Category)admin.site.register(Category, CategoryAdmin)