feat(apps): Add django-import-export
This commit is contained in:
parent
224f9df858
commit
97dc77fd5d
3 changed files with 20 additions and 3 deletions
|
@ -61,6 +61,7 @@ in
|
||||||
ps.django-bulma-forms
|
ps.django-bulma-forms
|
||||||
ps.django-compressor
|
ps.django-compressor
|
||||||
ps.django-debug-toolbar
|
ps.django-debug-toolbar
|
||||||
|
ps.django-import-export
|
||||||
ps.django-sass-processor
|
ps.django-sass-processor
|
||||||
ps.django-sass-processor-dart-sass
|
ps.django-sass-processor-dart-sass
|
||||||
ps.django-stubs
|
ps.django-stubs
|
||||||
|
|
|
@ -28,16 +28,21 @@ ADMINS = credentials.get_json("ADMINS", [])
|
||||||
# List the installed applications
|
# List the installed applications
|
||||||
|
|
||||||
INSTALLED_APPS = [
|
INSTALLED_APPS = [
|
||||||
|
# Unfold apps
|
||||||
"unfold",
|
"unfold",
|
||||||
|
"unfold.contrib.import_export",
|
||||||
|
# Django standard apps
|
||||||
"django.contrib.admin",
|
"django.contrib.admin",
|
||||||
"django.contrib.auth",
|
"django.contrib.auth",
|
||||||
"django.contrib.contenttypes",
|
"django.contrib.contenttypes",
|
||||||
"django.contrib.sessions",
|
"django.contrib.sessions",
|
||||||
"django.contrib.messages",
|
"django.contrib.messages",
|
||||||
|
# Custom apps
|
||||||
"shared.staticfiles.StaticFilesApp", # Overrides the default staticfiles app to filter out the sccs sources
|
"shared.staticfiles.StaticFilesApp", # Overrides the default staticfiles app to filter out the sccs sources
|
||||||
"django_browser_reload",
|
"django_browser_reload",
|
||||||
"sass_processor",
|
"sass_processor",
|
||||||
"bulma",
|
"bulma",
|
||||||
|
"import_export",
|
||||||
# Authentication
|
# Authentication
|
||||||
"allauth",
|
"allauth",
|
||||||
"allauth.account",
|
"allauth.account",
|
||||||
|
|
|
@ -1,15 +1,26 @@
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
|
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
|
||||||
|
from import_export.admin import ImportExportMixin
|
||||||
from unfold.admin import ModelAdmin
|
from unfold.admin import ModelAdmin
|
||||||
|
from unfold.contrib.import_export.forms import (
|
||||||
|
ExportForm,
|
||||||
|
ImportForm,
|
||||||
|
SelectableFieldsExportForm,
|
||||||
|
)
|
||||||
|
|
||||||
from dgsi.models import Bylaws, Service, Statutes, Translation, User
|
from dgsi.models import Bylaws, Service, Statutes, Translation, User
|
||||||
|
|
||||||
|
|
||||||
@admin.register(User)
|
@admin.register(User)
|
||||||
class UserAdmin(BaseUserAdmin, ModelAdmin):
|
class UserAdmin(BaseUserAdmin, ImportExportMixin, ModelAdmin):
|
||||||
pass
|
import_form_class = ImportForm
|
||||||
|
export_form_class = ExportForm
|
||||||
|
export_form_class = SelectableFieldsExportForm
|
||||||
|
|
||||||
|
|
||||||
@admin.register(Bylaws, Service, Statutes, Translation)
|
@admin.register(Bylaws, Service, Statutes, Translation)
|
||||||
class AdminClass(ModelAdmin):
|
class AdminClass(ImportExportMixin, ModelAdmin):
|
||||||
compressed_fields = True
|
compressed_fields = True
|
||||||
|
import_form_class = ImportForm
|
||||||
|
export_form_class = ExportForm
|
||||||
|
export_form_class = SelectableFieldsExportForm
|
||||||
|
|
Loading…
Reference in a new issue