June 2018
Beginner
508 pages
13h 8m
English
The next step is to hook the Entry model up with the admin panel. You can do it with one line of code, but in this case, I want to add some options to customize the way the admin panel shows the entries, both in the list view of all entry items in the database and in the form view that allows us to create and modify them.
All we need to do is to add the following code:
# entries/admin.pyfrom django.contrib import adminfrom .models import Entry@admin.register(Entry)class EntryAdmin(admin.ModelAdmin): fieldsets = [ ('Regular Expression', {'fields': ['pattern', 'test_string']}), ('Other Information', {'fields': ['user', 'date_added']}), ] list_display = ('pattern', 'test_string', 'user') list_filter = ['user'] search_fields ...Read now
Unlock full access