diff --git a/polls/admin.py b/polls/admin.py index 543e5a95db..5536852cba 100644 --- a/polls/admin.py +++ b/polls/admin.py @@ -9,7 +9,7 @@ class ChoiceInline(admin.TabularInline): # or admin.StackedInline for a differe @admin.register(Poll) class PollAdmin(admin.ModelAdmin): list_display = ["text", "owner", "pub_date", "active", "created_at"] - search_fields = ["text", "owner__username"] + search_fields = ["text", "description", "owner__username"] list_filter = ["active", 'created_at', 'pub_date'] date_hierarchy = "pub_date" inlines = [ChoiceInline] diff --git a/polls/forms.py b/polls/forms.py index 935ae133f3..b496bc3bd0 100644 --- a/polls/forms.py +++ b/polls/forms.py @@ -11,18 +11,20 @@ class PollAddForm(forms.ModelForm): class Meta: model = Poll - fields = ['text', 'choice1', 'choice2'] + fields = ['text', 'description', 'choice1', 'choice2'] widgets = { 'text': forms.Textarea(attrs={'class': 'form-control', 'rows': 5, 'cols': 20}), + 'description': forms.Textarea(attrs={'class': 'form-control', 'rows': 3, 'cols': 20}), } class EditPollForm(forms.ModelForm): class Meta: model = Poll - fields = ['text', ] + fields = ['text', 'description'] widgets = { 'text': forms.Textarea(attrs={'class': 'form-control', 'rows': 5, 'cols': 20}), + 'description': forms.Textarea(attrs={'class': 'form-control', 'rows': 3, 'cols': 20}), } diff --git a/polls/models.py b/polls/models.py index 0a21e98292..ba4690b924 100644 --- a/polls/models.py +++ b/polls/models.py @@ -7,6 +7,7 @@ class Poll(models.Model): owner = models.ForeignKey(User, on_delete=models.CASCADE) text = models.TextField() + description = models.TextField(blank=True, default='') pub_date = models.DateTimeField(default=timezone.now) active = models.BooleanField(default=True) created_at = models.DateTimeField(auto_now_add=True) diff --git a/polls/templates/polls/add_poll.html b/polls/templates/polls/add_poll.html index e07416f118..e1c9d2aabb 100644 --- a/polls/templates/polls/add_poll.html +++ b/polls/templates/polls/add_poll.html @@ -27,4 +27,4 @@
{{ poll.description }}
+ {% endif %}{{ poll.description }}
+ {% endif %}{{ poll.description }}
+ {% endif %}