fix clicking add tag when no tag is selected throwing 500
This commit is contained in:
parent
76ff789164
commit
177d22da50
2 changed files with 6 additions and 6 deletions
|
@ -49,7 +49,6 @@ from django.contrib.admin.helpers import ActionForm
|
||||||
|
|
||||||
class SnapshotActionForm(ActionForm):
|
class SnapshotActionForm(ActionForm):
|
||||||
tag = forms.ModelChoiceField(queryset=Tag.objects.all(), required=False)
|
tag = forms.ModelChoiceField(queryset=Tag.objects.all(), required=False)
|
||||||
# pass
|
|
||||||
|
|
||||||
|
|
||||||
class SnapshotAdmin(SearchResultsAdminMixin, admin.ModelAdmin):
|
class SnapshotAdmin(SearchResultsAdminMixin, admin.ModelAdmin):
|
||||||
|
@ -214,6 +213,7 @@ class SnapshotAdmin(SearchResultsAdminMixin, admin.ModelAdmin):
|
||||||
delete_snapshots.short_description = "Delete"
|
delete_snapshots.short_description = "Delete"
|
||||||
|
|
||||||
def add_tag(self, request, queryset):
|
def add_tag(self, request, queryset):
|
||||||
|
if tag and tag.id:
|
||||||
tag = request.POST['tag']
|
tag = request.POST['tag']
|
||||||
for obj in queryset:
|
for obj in queryset:
|
||||||
obj.tags.add(tag)
|
obj.tags.add(tag)
|
||||||
|
|
|
@ -32,8 +32,8 @@ class Tag(models.Model):
|
||||||
"""
|
"""
|
||||||
Based on django-taggit model
|
Based on django-taggit model
|
||||||
"""
|
"""
|
||||||
name = models.CharField(verbose_name="name", unique=True, blank=False, max_length=100)
|
name = models.CharField(unique=True, blank=False, max_length=100)
|
||||||
slug = models.SlugField(verbose_name="slug", unique=True, blank=True, max_length=100)
|
slug = models.SlugField(unique=True, blank=True, max_length=100)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = "Tag"
|
verbose_name = "Tag"
|
||||||
|
|
Loading…
Reference in a new issue