prepopulated_fields slug django two column code example
Example 1: prepopulated_fields = {'slug': ('name',)}
class CategoryAdmin(admin.ModelAdmin):
prepopulated_fields = {'slug': ['name']}
admin.site.register(Category, CategoryAdmin)
Example 2: prepopulated_fields = {'slug': ('name',)}
from django.contrib import admin
from .models import Category, Recipe
class CategoryAdmin(admin.ModelAdmin):
prepopulated_fields = {'slug': ['name']}
class RecipeAdmin(admin.ModelAdmin):
prepopulated_fields = {'slug': ['title']}
admin.site.register(Category, CategoryAdmin)
admin.site.register(Recipe, RecipeAdmin)