Answer the question
In order to leave comments, you need to log in
Some fields are not showing up in the django admin. Actually, why?
Model:
class Category(MPTTModel):
...
created_at = models.DateTimeField(auto_now_add=True, null=True, blank=True, verbose_name='Дата создания')
updated_at = models.DateTimeField(auto_now = True, null=True, blank=True, verbose_name='Дата редактирования')
...
from django.contrib import admin
from django_mptt_admin.admin import DjangoMpttAdmin
from .models import Category
class CategoryAdmin(DjangoMpttAdmin, admin.ModelAdmin):
tree_title_field = 'Категория'
tree_display = ('name',)
list_display = ['id', 'name', 'parent', 'thumb', 'alias', 'image']
search_fields = ['name']
readonly_fields = ['created_at', 'updated_at', 'thumb']
fields = (('name', 'alias', 'parent'), 'description', 'image', 'thumb')
list_display_links = ('name', 'alias', 'thumb')
prepopulated_fields = {"alias": ("name",)}
admin.site.register(Category, CategoryAdmin)
Answer the question
In order to leave comments, you need to log in
created_at = models.DateTimeField(editable=True, ...)
updated_at = models.DateTimeField(editable=True, ...)
auto_now_add=True
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question