You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

19 lines
538 B
Python

from django.contrib import admin
from .models import Page
from pathlib import Path
def reimport(modeladmin, request, queryset):
for page in queryset:
path = Path(__file__).resolve().parent / "default_content" / f"{page.url}.html"
if path.exists():
page.content = path.read_text()
page.save()
@admin.register(Page)
class PageAdmin(admin.ModelAdmin):
fields = ("url", "content", "title", "visible", "kind")
list_display = ("url", "title", "visible", "kind")
actions = (reimport,)