How to give package names to django javascript_catalog view?

后端 未结 3 2161
甜味超标
甜味超标 2020-12-31 21:46

From django documentation:

js_info_dict = { \'packages\': (\'your.app.package\',), }

urlpatterns = patterns(\'\', (r\'^jsi18n/

相关标签:
3条回答
  • 2020-12-31 21:55

    Try adding 'my_project_dir' to INSTALLED_APPS in settings.py

    0 讨论(0)
  • 2020-12-31 21:59

    For others with my particular case, js messages are generated and compiled OK but not rendered in templates or pages when you use i18n language urls.

    This is because javascript catalog should be added to i18n urls patterns, not to normal patterns.

    urlpatterns += patterns('', (r'^jsi18n/$', 'django.views.i18n.javascript_catalog', js_info_dict), )
    

    =>

    urlpatterns += i18n_patterns('', (r'^jsi18n/$', 'django.views.i18n.javascript_catalog', js_info_dict), )
    
    0 讨论(0)
  • 2020-12-31 22:03

    First you need to be sure that your js_info_dict is like this:

    js_info_dict = {
        'domain': 'djangojs',
        'packages': ('my_project_name',),
    }
    

    And as @daonb suggested, add 'my_project_name' to your INSTALLED_APPS in settings.py.

    Make sure that you compile your messages like this:

    django-admin.py makemessages -a -d djangojs
    

    That's all!

    I don't know why Django doesn't have that information into its documentation. I could find the solution with using these articles below:

    http://www.aminche.com/blog/2010/07/06/playground-editor http://code.djangoproject.com/ticket/5494 http://osdir.com/ml/django-users/2010-04/msg00231.html

    0 讨论(0)
提交回复
热议问题