Commit c3936c0d authored by Bouke Haarsma's avatar Bouke Haarsma
Browse files

Fixed #9523 -- Restart runserver after translation MO files change

Thanks to Krzysztof Kulewski for the initial patch.
parent 090315f5
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -369,6 +369,7 @@ answer newbie questions, and generally made Django that much better:
    knox <christobzr@gmail.com>
    David Krauth
    Kevin Kubasik <kevin@kubasik.net>
    Krzysztof Kulewski <kulewski@gmail.com>
    kurtiss@meetro.com
    Vladimir Kuzma <vladimirkuzma.ch@gmail.com>
    Denis Kuzmichyov <kuzmichyov@gmail.com>
+18 −3
Original line number Diff line number Diff line
@@ -28,13 +28,13 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import datetime
import os
import signal
import sys
import time
import traceback

from django.conf import settings
from django.core.signals import request_finished
try:
    from django.utils.six.moves import _thread as thread
@@ -86,13 +86,28 @@ _win = (sys.platform == "win32")

_error_files = []


def gen_filenames():
    """
    Yields a generator over filenames referenced in sys.modules.
    Yields a generator over filenames referenced in sys.modules and translation
    files.
    """
    filenames = [filename.__file__ for filename in sys.modules.values()
                if hasattr(filename, '__file__')]

    # Add the names of the .mo files that can be generated
    # by compilemessages management command to the list of files watched.
    basedirs = [os.path.join(os.path.dirname(os.path.dirname(__file__)),
                             'conf', 'locale'),
                'locale']
    basedirs.extend(settings.LOCALE_PATHS)
    basedirs = [os.path.abspath(basedir) for basedir in basedirs
                if os.path.isdir(basedir)]
    for basedir in basedirs:
        for dirpath, dirnames, locale_filenames in os.walk(basedir):
            for filename in locale_filenames:
                if filename.endswith('.mo'):
                    filenames.append(os.path.join(dirpath, filename))

    for filename in filenames + _error_files:
        if not filename:
            continue
+6 −2
Original line number Diff line number Diff line
@@ -791,8 +791,12 @@ Django.)

The development server automatically reloads Python code for each request, as
needed. You don't need to restart the server for code changes to take effect.
However, some actions like adding files or compiling translation files don't
trigger a restart, so you'll have to restart the server in these cases.
However, some actions like adding files don't trigger a restart, so you'll 
have to restart the server in these cases.

.. versionchanged:: 1.7

    Compiling translation files now also restarts the development server.

If you are using Linux and install `pyinotify`_, kernel signals will be used to
autoreload the server (rather than polling file modification timestamps each
+3 −0
Original line number Diff line number Diff line
@@ -346,6 +346,9 @@ Management Commands
* The :djadmin:`runserver` command now uses ``inotify`` Linux kernel signals
  for autoreloading if ``pyinotify`` is installed.

* The :djadmin:`runserver` command is now restarted when a translation file is
  changed.

Models
^^^^^^

+367 B

File added.

No diff preview for this file type.

Loading