1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Added JS for SlugField autofill

This commit is contained in:
Jeremy Stretch
2016-05-20 15:32:17 -04:00
parent 5a2946b146
commit bbdc7dccba
7 changed files with 47 additions and 6 deletions

View File

@ -203,6 +203,15 @@ class FlexibleModelChoiceField(forms.ModelChoiceField):
return value
class SlugField(forms.SlugField):
def __init__(self, slug_source='name', *args, **kwargs):
label = kwargs.pop('label', "Slug")
help_text = kwargs.pop('help_text', "URL-friendly unique shorthand")
super(SlugField, self).__init__(label=label, help_text=help_text, *args, **kwargs)
self.widget.attrs['slug-source'] = slug_source
#
# Forms
#