Django: IE doesn't load localhost or loads very SLOWLY

后端 未结 5 2056
迷失自我
迷失自我 2021-01-12 03:40

I\'m just starting to learn Django, building a project on my computer, running Windows 7 64-bit, Python 2.7, Django 1.3.

Basically whatever I write, it loads in Chro

5条回答
  •  执笔经年
    2021-01-12 04:11

    i had this issue too, this workaround does the fix. works only for django <= 1.3
    http://nedbatchelder.com/blog/201103/quick_and_dirty_multithreaded_django_dev_server.html

    @Andrew Barber
    EDIT summary/how i did that:
    create a file named managec.py (c=concurrent)
    paste the following code in there:

    #!/usr/bin/env python
    # 
    # A clone of manage.py, with multi-threadedness monkeypatched in.
    
    import os, sys
    from django.core.management import execute_manager
    try:
        import settings # Assumed to be in the same directory.
    except ImportError:
        sys.stderr.write(
            "Error: Can't find the file 'settings.py' in the directory containing %r. "
            "It appears you've customized things.\n"
            "You'll have to run django-admin.py, passing it your settings module.\n"
            "(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" 
            % __file__
            )
        sys.exit(1)
    
    def monkey_patch_for_multi_threaded():
        # This monkey-patches BaseHTTPServer to create a base HTTPServer class that 
        # supports multithreading 
        import BaseHTTPServer, SocketServer 
        OriginalHTTPServer = BaseHTTPServer.HTTPServer
    
        class ThreadedHTTPServer(SocketServer.ThreadingMixIn, OriginalHTTPServer): 
            def __init__(self, server_address, RequestHandlerClass=None): 
                OriginalHTTPServer.__init__(self, server_address, RequestHandlerClass) 
    
        BaseHTTPServer.HTTPServer = ThreadedHTTPServer
    
    if __name__ == "__main__":
        monkey_patch_for_multi_threaded()
        execute_manager(settings)
    


    start your dev server with ./managec.py runserver 8080 (or whatever port you use)
    enjoy :)

提交回复
热议问题