Admin and API
As the last part of the chapter, we describe briefly some possible admin management of the model and the implementation of an API endpoint to retrieve the data processed by the application. In the pages
folder, we can set two admin interfaces in the admin.py
file to check the data collected by the SearchTerm
and Page
models:
from django.contrib import admin from django_markdown.admin import MarkdownField, AdminMarkdownWidget from pages.models import SearchTerm,Page,Link class SearchTermAdmin(admin.ModelAdmin): formfield_overrides = {MarkdownField: {'widget': AdminMarkdownWidget}} list_display = ['id', 'term', 'num_reviews'] ordering = ['-id'] class PageAdmin(admin.ModelAdmin): formfield_overrides = {MarkdownField: {'widget': AdminMarkdownWidget}} list_display = ['id', 'searchterm', 'url','title','content'] ordering = ['-id','-new_rank'] admin.site.register(SearchTerm,SearchTermAdmin) admin.site.register(Page,PageAdmin) admin.site.register...