3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Django1.9 で表示される言語を切り替える

Posted at

#環境
Ubuntu 14.04.4 LTS
Python 3.5.1
Django 1.9.7

#前提条件

以下の手順を行うことで、
http://hoge.com/ja/huga で日本語
http://hoge.com/en/huga で英語
等の切替を行うことができます。

#手順

##urls.pyの変更

  • path/to/project/project/urls.pyに以下を追記

    urls.py
    from django.conf.urls.i18n import i18n_patterns
    
    urls.py
    urlpatterns += i18n_patterns('',
        # admin ページの言語を切り替えたい場合
        url(r'^admin/', include(admin.site.urls)),
    
        # myapp という app の言語を切り替えたい場合
        url(r'^myapp/', include('myapp.urls', namespace='myapp')),
    )
    

これだけで、言語の切替ができるようになります。

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?