I'm still quite new to Django, so after finishing the official tutorial I'm trying to learn more by steps and attempts to solve common problems.
I'm currently stuck with finding a (possibily correct) way to have localized datepickers in my app's admin page, which works with django-grappelli.
I was trying to directly modify grappelli files, but I feel this might definitely not be the correct approach.
My app is quite simple, not very distant from where you are left with after the official tutorial.
I've slightly modified the admin.py file, like this:
[...]
@admin.register(Question)
class QuestionAdmin(admin.ModelAdmin):
#fields = ['pub_date', 'question_text']
#date_hierarchy = 'pub_date'
class Media:
js = ("/media/mytime/js/ui.datepicker-it.js",)
list_display = ['question_text', 'pub_date']
fieldsets = [
(None, {'fields': ['question_text']}),
('+ Date information', {'fields': ['pub_date'], 'classes': ['grp-collapse grp-closed']}),
]
inlines = [ChoiceInline]
actions = ['prepend_letter']
[...]
By adding:
class Media:
js = ("/media/mytime/js/ui.datepicker-it.js",)
and correctly putting the file in the media directory, now the file appears in the page source code when browsing to the Question modification page.
Too bad this seems not to be enough, as the datepickers are still appearing untranslated.
I've tried to even inject directly via console the line:
$.datepicker.setDefaults( $.datepicker.regional[ "it" ] );
but it looks like I'm still far from doing it right. Any tips?