Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use admin site autodiscovery. Extracted admin code into admin.py. Sho…
…w off new ModelAdmin translation code.
- Loading branch information
joost@cassee.net
committed
Jul 23, 2008
1 parent
3047e32
commit 8ef73d1
Showing
3 changed files
with
31 additions
and
33 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from django import forms | ||
from django.contrib import admin | ||
from multilingual import translation | ||
from articles import models | ||
|
||
class CategoryAdmin(admin.ModelAdmin): | ||
# Field names would just work here, but if you need | ||
# correct list headers (from field.verbose_name) you have to | ||
# use the get_'field_name' functions here. | ||
list_display = ('id', 'creator', 'created', 'name', 'description') | ||
search_fields = ('name', 'description') | ||
|
||
class ArticleAdmin(admin.ModelAdmin): | ||
class Translation(translation.TranslationModelAdmin): | ||
def formfield_for_dbfield(self, db_field, **kwargs): | ||
field = super(translation.TranslationModelAdmin, self).formfield_for_dbfield(db_field, **kwargs) | ||
if db_field.name == 'contents': | ||
field.widget = forms.Textarea(attrs={'cols': 50}) | ||
return field | ||
|
||
admin.site.register(models.Article, ArticleAdmin) | ||
admin.site.register(models.Category, CategoryAdmin) |
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
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