I have problem to display clickable link in django admin panel next to 
'icon' field or add help_text witch will be clickable and if i click on it, 
it must open this 'https://fonts.google.com/icons?icon.set=Material+Icons' 
website in new window of browther .

[image: 1111.PNG]

link example : https://fonts.google.com/icons?icon.set=Material+Icons

I tried this but nothing happens, it shows just normal models without link 
and text.

**admin.py **
from .models import RaffleGame from django.utils.html import format_html 
from django.urls import reverse from django.contrib import admin class 
RaffleGameAdmin(admin.ModelAdmin): list_display = ('icon', 'link_to_google') 
def link_to_google(self, obj): url = 
'https://fonts.google.com/icons?icon.set=Material+Icons' link_text = 'click 
me for more info' return format_html('<a href="{}">{}</a>', url, link_text) 
link_to_google.short_description = 'Mehr Icons findest du hier' 
admin.site.register(RaffleGame, RaffleGameAdmin) 

*models.py*
class RaffleGame(models.Model): class GameStatus(models.TextChoices): 
scheduled = 'scheduled' announced = 'announced' draw_day = 'draw_day' drawn 
= 'drawn' finished = 'finished' class IconColor(models.TextChoices): red = 
'red' yellow = 'yellow' black = 'black' green = 'green' title = models.
CharField(max_length=500, default='PiA-Gewinnspiel', verbose_name='Titel') 
status = models.CharField(max_length=100, choices=GameStatus.choices, 
default=GameStatus.scheduled, verbose_name='Status', editable=False) 
announcement_date = models.DateField(verbose_name='Spiel ankündigen ab') 
draw_date = models.DateTimeField(verbose_name='Zeitpunkt der Auslosung') 
finished_date = models.DateField(verbose_name='Gewinner anzeigen bis') icon 
= models.CharField(max_length=100, default='park', verbose_name='Icon') 
icon_color = models.CharField(max_length=100, choices=IconColor.choices, 
default=IconColor.black, verbose_name='Icon Farbe') icon_outlined = models.
BooleanField(default=False, verbose_name='Icon outlined') class Meta: 
db_table = "RaffleGame" def __str__(self): return self.title

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/634c7481-842c-4eb7-b198-57c7d5bc3a66n%40googlegroups.com.

Reply via email to