summaryrefslogtreecommitdiff
path: root/app/pages/admin.py
blob: b5e41b48f1f6daea75343bdc503e36ea73e0ac03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from django.contrib import admin

from django import forms
from django.forms import Textarea
from django.db import models

from pages.models import Page

class PageEntryForm(forms.ModelForm):
    class Meta:
        model = Page
        fields = '__all__'
        widgets = {
            'body_markdown': forms.Textarea(attrs={'rows': 50, 'cols': 100}),
        }

class PageAdmin(admin.ModelAdmin):
    form = PageEntryForm
    
    list_display = ('title', 'slug',)
    search_fields = ['title', 'body_markdown']
    prepopulated_fields = {"slug": ('title',)}
    fieldsets = (
        ('Page', {
            'fields': ('title', 'body_markdown', ('slug', 'path', 'app')),
            'classes': ('show', 'extrapretty', 'wide')
        }),
        ('Metadata', {
            'classes': ('collapse closed',),
            'fields': ('meta_description',),
        })
    )

admin.site.register(Page, PageAdmin)