Quantcast
Viewing latest article 10
Browse Latest Browse All 10

Default (initial) value in Django's admin for a choice field

I was trying to set the initial value for a choice field in the admin like this: from django import forms from django.contrib import admin from mptt.admin import MPTTModelAdmin from author.models import Author from serials.constants import STATUS_CHOICES class AuthorAdminForm(forms.ModelForm): class Meta: model = Author class AuthorAdmin(MPTTModelAdmin): form = AuthorAdminForm(initial={'status': STATUS_CHOICES[0][0]}) admin.site.register(Author, AuthorAdmin) Logically, I should […]

Viewing latest article 10
Browse Latest Browse All 10

Trending Articles