Skip to content

Commit

Permalink
feat: use unfold admin template
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelovicentegc committed Jun 21, 2024
1 parent 04ace2f commit a3179ff
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 15 deletions.
3 changes: 2 additions & 1 deletion backend/admin/publications.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from django.contrib import admin
from unfold.admin import ModelAdmin
from django.utils.html import format_html
from django_better_admin_arrayfield.admin.mixins import DynamicArrayMixin
from backend.models.publications import Publication
from backend.actions import ExportCsvMixin
from backend.utils import Strings

@admin.register(Publication)
class PublicationAdmin(admin.ModelAdmin, DynamicArrayMixin):
class PublicationAdmin(ModelAdmin, DynamicArrayMixin):
def image_preview(self, obj):
return format_html('<img src="{}" style="height: 150px" />'.format(obj.image.url))

Expand Down
3 changes: 2 additions & 1 deletion backend/admin/subscribers.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from django.contrib import admin
from unfold.admin import ModelAdmin
from backend.models.subscribers import Subscriber
from backend.actions import ExportCsvMixin


@admin.register(Subscriber)
class SubscriberAdmin(admin.ModelAdmin, ExportCsvMixin):
class SubscriberAdmin(ModelAdmin, ExportCsvMixin):
list_filter = ('contact_method', 'created_at')
actions = ["export_as_csv"]
search_fields = ['name']
Expand Down
8 changes: 7 additions & 1 deletion core/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@
# Application definition

INSTALLED_APPS = [
'jazzmin',
"unfold", # before django.contrib.admin
"unfold.contrib.filters", # optional, if special filters are needed
"unfold.contrib.forms", # optional, if special form elements are needed
"unfold.contrib.inlines", # optional, if special inlines are needed
# "unfold.contrib.import_export", # optional, if django-import-export package is used
# "unfold.contrib.guardian", # optional, if django-guardian package is used
# "unfold.contrib.simple_history", # optional, if django-simple-history package is used
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
Expand Down
4 changes: 0 additions & 4 deletions core/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@
admin.site.site_title = "Django-React-Typescript Admin"
admin.site.index_title = "Modules"

def trigger_error(request):
division_by_zero = 1 / 0

urlpatterns = [
re_path(r'^sentry-debug/', trigger_error),
re_path(r'^admin/', admin.site.urls),
re_path(r'^api/', include('api.urls')),
re_path(r'^static/(?P<path>.*)$', serve, { 'document_root' : STATIC_ROOT, }),
Expand Down
14 changes: 7 additions & 7 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ django-filter = "^24.2"
django-better-admin-arrayfield = "^1.4.2"
twilio = "^9.1.1"
psycopg2-binary = "^2.9.9"
django-jazzmin = "^3.0.0"
django-unfold = "^0.28.1"

[build-system]
requires = ["poetry-core"]
Expand Down

0 comments on commit a3179ff

Please sign in to comment.