2019-06-14 16:20:29 +00:00
|
|
|
from django import forms
|
2015-12-26 17:46:51 +00:00
|
|
|
from django.contrib import admin
|
|
|
|
|
2015-12-26 18:51:22 +00:00
|
|
|
from .models import Article, ArticleProxy, Site
|
|
|
|
|
|
|
|
|
2019-06-14 16:20:29 +00:00
|
|
|
class ArticleAdminForm(forms.ModelForm):
|
|
|
|
nolabel_form_field = forms.BooleanField(required=False)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = Article
|
|
|
|
fields = ['title']
|
|
|
|
|
|
|
|
@property
|
|
|
|
def changed_data(self):
|
|
|
|
data = super().changed_data
|
|
|
|
if data:
|
|
|
|
# Add arbitrary name to changed_data to test
|
|
|
|
# change message construction.
|
|
|
|
return data + ['not_a_form_field']
|
|
|
|
return data
|
|
|
|
|
|
|
|
|
2015-12-26 18:51:22 +00:00
|
|
|
class ArticleInline(admin.TabularInline):
|
|
|
|
model = Article
|
|
|
|
fields = ['title']
|
2019-06-14 16:20:29 +00:00
|
|
|
form = ArticleAdminForm
|
2015-12-26 18:51:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
class SiteAdmin(admin.ModelAdmin):
|
|
|
|
inlines = [ArticleInline]
|
|
|
|
|
2015-12-26 17:46:51 +00:00
|
|
|
|
|
|
|
site = admin.AdminSite(name='admin')
|
|
|
|
site.register(Article)
|
|
|
|
site.register(ArticleProxy)
|
2015-12-26 18:51:22 +00:00
|
|
|
site.register(Site, SiteAdmin)
|