Answers for "prepopulated_fields = {'slug': ('name',)}"

0

prepopulated_fields = {'slug': ('name',)}

class CategoryAdmin(admin.ModelAdmin):
    prepopulated_fields = {'slug': ['name']}


admin.site.register(Category, CategoryAdmin)
Posted by: Guest on November-06-2020
0

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)
Posted by: Guest on November-06-2020

Browse Popular Code Answers by Language