-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from arpithpm/add-admin-filters-for-models
Add admin filters for models.py
- Loading branch information
Showing
2 changed files
with
37 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,41 @@ | ||
from django.contrib import admin | ||
from .models import Category, Prompt, Label, PromptLabel | ||
from .models import Category, Prompt, Label, PromptLabel, Profile | ||
from reversion.admin import VersionAdmin | ||
|
||
# Register your models here. | ||
@admin.register(Category) | ||
class YourModelAdmin(VersionAdmin): | ||
pass | ||
|
||
admin.site.register([Prompt, Label, PromptLabel]) | ||
|
||
|
||
class ProfileAdmin(admin.ModelAdmin): | ||
list_display = ('user', 'avatar') | ||
|
||
|
||
class CategoryAdmin(admin.ModelAdmin): | ||
list_display = ('name', 'created_at', 'modified_at', 'help_text') | ||
search_fields = ('name',) | ||
list_filter = ('created_at', 'modified_at') | ||
|
||
|
||
class PromptAdmin(admin.ModelAdmin): | ||
list_display = ('text', 'category', 'created_at', 'modified_at', 'owner', 'is_public', 'text_hash') | ||
search_fields = ('text', 'owner__username') | ||
list_filter = ('category', 'created_at', 'modified_at', 'owner', 'is_public') | ||
|
||
|
||
class LabelAdmin(admin.ModelAdmin): | ||
list_display = ('name', 'created_at', 'modified_at') | ||
search_fields = ('name',) | ||
list_filter = ('created_at', 'modified_at') | ||
|
||
|
||
class PromptLabelAdmin(admin.ModelAdmin): | ||
list_display = ('label', 'prompt') | ||
search_fields = ('label__name', 'prompt__text') | ||
list_filter = ('label', 'prompt') | ||
|
||
|
||
admin.site.register(Profile, ProfileAdmin) | ||
admin.site.register(Category, CategoryAdmin) | ||
admin.site.register(Prompt, PromptAdmin) | ||
admin.site.register(Label, LabelAdmin) | ||
admin.site.register(PromptLabel, PromptLabelAdmin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters