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
|
2022-02-03 19:24:19 +00:00
|
|
|
fields = ["title"]
|
2019-06-14 16:20:29 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def changed_data(self):
|
|
|
|
data = super().changed_data
|
|
|
|
if data:
|
|
|
|
# Add arbitrary name to changed_data to test
|
|
|
|
# change message construction.
|
2022-02-03 19:24:19 +00:00
|
|
|
return data + ["not_a_form_field"]
|
2019-06-14 16:20:29 +00:00
|
|
|
return data
|
|
|
|
|
|
|
|
|
2015-12-26 18:51:22 +00:00
|
|
|
class ArticleInline(admin.TabularInline):
|
|
|
|
model = Article
|
2022-02-03 19:24:19 +00:00
|
|
|
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
|
|
|
|
2022-02-03 19:24:19 +00:00
|
|
|
site = admin.AdminSite(name="admin")
|
2015-12-26 17:46:51 +00:00
|
|
|
site.register(Article)
|
|
|
|
site.register(ArticleProxy)
|
2015-12-26 18:51:22 +00:00
|
|
|
site.register(Site, SiteAdmin)
|