Why not working ?

23 views
Skip to first unread message

setivo...@gmail.com

unread,
Feb 29, 2016, 11:39:54 AM2/29/16
to Django users

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)






Nikolas Stevenson-Molnar

unread,
Feb 29, 2016, 2:30:28 PM2/29/16
to Django users
Please be more specific. What isn't working? What is the desired vs actual result?
Reply all
Reply to author
Forward
0 new messages