my model
.........................
class Translator(models.Model):
"""
Model for dictionaries tranlations
"""
def dispatch_dictionary_media_files(instance, filename):
return 'app_dictionaries/{0}/{1}'.format(instance.name.__str__(),
filename)
author = models.ForeignKey(settings.AUTH_USER_MODEL)
*name = models.CharField('Name of translator', max_length=50,
unique=True)*
language_origin = models.CharField('Origin language', max_length=30,
choices=LANGUAGES)
language_translation = models.CharField('Language of translation',
max_length=30, choices=LANGUAGES)
picture = models.ImageField('Picture for translator',
upload_to=dispatch_dictionary_media_files, blank=True, null=True)
description = models.TextField('Description of translator', null=True,
blank=True)
*slug_name = models.SlugField('Name for link', unique=True)*
rating = models.DecimalField('Rating', max_digits=4, decimal_places=2,
editable=False, default=0)
date_added = models.DateTimeField('Date added', auto_now_add=True)
my admin.py
--------------------------------------
class AdminTranslator(admin.ModelAdmin):
fieldsets = [
('Requred fields', {
'fields': ['name', 'author', ('slug_name',
'language_translation')],
}),
('Not required fields', {
'classes': ('collapse',),
'fields': ['description', 'picture'],
'description': 'It is fields nor required. And you may skip
it.',
}),
]
date_hierarchy = 'date_added'
actions_on_top = True
actions_on_bottom = True
empty_value_display = '-empty-'
* prepopulated_fields = {"slug_name": ("name",)}*
inlines = [AddTranslationInline]
# -----------------------------------------
list_display = ['name', 'author', 'language_origin',
'language_translation', 'rating', 'was_added_recently', 'date_added']
list_filter = ['date_added']
search_fields = ['name']
*admin.site.register(Translator, AdminTranslator)*
<https://lh3.googleusercontent.com/-W6Sib46OFQE/VtR0BoC7wPI/AAAAAAAAAAc/lCOBPMKyq78/s1600/Screenshot%2Bfrom%2B2016-02-29%2B18%253A36%253A53.png>
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/d08afe6f-b993-4129-83f7-b8853f3f66e3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.