1
0
mirror of https://github.com/Damillora/Altessimo synced 2024-11-24 06:37:33 +00:00
Altessimo/categories/admin.py

48 lines
1.2 KiB
Python
Raw Normal View History

2020-12-15 21:32:20 +00:00
from django.contrib import admin
2020-12-17 12:21:37 +00:00
from django import forms
2020-12-15 21:32:20 +00:00
2020-12-17 12:21:37 +00:00
from .models import Branch, Category
2020-12-15 21:32:20 +00:00
# Register your models here.
2020-12-17 12:21:37 +00:00
class BranchForm(forms.ModelForm):
class Meta:
model = Branch
exclude = []
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['description'].widget.attrs['class'] = 'tm-textfield'
class CategoryForm(forms.ModelForm):
class Meta:
model = Category
exclude = []
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['description'].widget.attrs['class'] = 'tm-textfield'
2020-12-16 14:26:15 +00:00
class BranchAdmin(admin.ModelAdmin):
2020-12-17 12:21:37 +00:00
form = BranchForm
2020-12-16 14:26:15 +00:00
search_fields = ['name', 'acronym']
2020-12-17 12:21:37 +00:00
class Media:
js = (
'https://cdnjs.cloudflare.com/ajax/libs/tinymce/5.6.2/tinymce.min.js',
'tinymce-init.js'
)
2020-12-16 14:26:15 +00:00
class CategoryAdmin(admin.ModelAdmin):
2020-12-17 12:21:37 +00:00
form = CategoryForm
2020-12-16 14:26:15 +00:00
search_fields = ['name']
2020-12-17 12:21:37 +00:00
class Media:
js = (
'https://cdnjs.cloudflare.com/ajax/libs/tinymce/5.6.2/tinymce.min.js',
'tinymce-init.js'
)
admin.site.register(Branch, BranchAdmin)
admin.site.register(Category,CategoryAdmin)