Skip to content

Commit

Permalink
Run django-upgrade manually
Browse files Browse the repository at this point in the history
  • Loading branch information
albertyw committed Jan 7, 2023
1 parent deb9b1f commit 8dfba68
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
16 changes: 7 additions & 9 deletions project/example_app/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
from .models import Blind


@admin.register(Blind)
class BlindAdmin(admin.ModelAdmin):
list_display = ('desc', 'thumbnail', 'name', 'child_safe')
list_editable = ('name', 'child_safe')

@admin.display(
description='Photo'
)
def thumbnail(self, obj):
try:
img_tag = '<img src="%s" width="200px"/>' % obj.photo.url
Expand All @@ -16,20 +20,14 @@ def thumbnail(self, obj):
url = self._blind_url(obj)
return f'<a href="{url}">{img_tag}</a>'

thumbnail.short_description = 'Photo'
thumbnail.allow_tags = True

def _blind_url(self, obj):
url = reverse('admin:example_app_blind_change', args=(obj.id, ))
return url

@admin.display(
description='Blind'
)
def desc(self, obj):
desc = str(obj)
url = self._blind_url(obj)
return f'<a href="{url}">{desc}</a>'

desc.short_description = 'Blind'
desc.allow_tags = True


admin.site.register(Blind, BlindAdmin)
7 changes: 4 additions & 3 deletions project/tests/urlconf_without_silk.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from django.urls import include, re_path
from django.urls import include, path


urlpatterns = [
re_path(
r'^example_app/',
path(
'example_app/',
include('example_app.urls', namespace='example_app')
),
]

0 comments on commit 8dfba68

Please sign in to comment.