Practical Django Projects. Page 50 Errata

The following line of code is no longer correct:

 slug = models.SlugField(prepopulate_form=['title'],unique=True)

Because the prepopulate_form attribute is something that only has meaning within the admin app, it now has to be put in the admin.py file. Assuming you have read the previous post, the content of admin.py should be the following:

from django.contrib import admin
from coltrane.models import Category

class CategoryAdmin(admin.ModelAdmin):
	model = Category
	prepopulated_fields = {
					"slug" : ("title",)
				}
admin.site.register(Category,CategoryAdmin)

Tags: ,

Leave a Reply