You want to add the onclick attribute to the button widget. This attribute will trigger a JavaScript function that redirects the user to a specified URL (https://example.com in this case) when the button is clicked. Am I right?
from django import forms
from django.utils.safestring import mark_safe
class FootballMapAdminForm(forms.ModelForm):
extra_link = forms.URLField(
label="Some Label",
widget=forms.URLInput(attrs={'style': "margin-bottom: 40px", "type": "button", "onclick": "window.location.href='https://example.com'"}),
)
def __init__(self, *args, **kwargs):
super(FootballMapAdminForm, self).__init__(*args, **kwargs)
self.fields["extra_link"].initial = "https://example.com"