ku-polls/polls/admin.py
sosokker 1b996629da Refine UI/UX - Add new Feature (Model) - Refine View
1. Refine UI/UX
Apply Tailwinds
Rewrite all page

2. Add new feature to model
Add new field
- description - long - short
- use default + editable instead of auto_add_now
- track up vote
- Change timezone
- Add time left track
-Add participant
-Add up/down vote attribute

-- Choice
- Add total_vote
-Add calculate_percentage of vote

3. Refine View
-Redirect instead of home page
-Add context to result, detail view
-Apply ChartJS
-Delete home
2023-09-09 21:20:23 +07:00

25 lines
708 B
Python

from django.contrib import admin
from .models import Choice, Question
class ChoiceInline(admin.TabularInline):
model = Choice
extra = 3
class QuestionAdmin(admin.ModelAdmin):
fieldsets = [
(None, {"fields": ["question_text"]}),
("End date", {"fields": ["end_date"], "classes": ["collapse"]}),
("Vote count", {"fields": ["up_vote_count", "down_vote_count"]}),
("Participant count", {"fields": ["participant_count"]}),
]
list_display = ["question_text", "pub_date", "end_date", "was_published_recently"]
inlines = [ChoiceInline]
list_filter = ["pub_date"]
search_fields = ["question_text"]
admin.site.register(Question, QuestionAdmin)