Code

Ticket #2600: SERVE_DEFAULT_ADMIN_MEDIA.diff

File SERVE_DEFAULT_ADMIN_MEDIA.diff, 1.9 KB (added by adurdin@…, 8 years ago)

patch

Line 
1Index: django/conf/project_template/settings.py
2===================================================================
3--- django/conf/project_template/settings.py    (revision 29)
4+++ django/conf/project_template/settings.py    (working copy)
5@@ -40,6 +40,10 @@
6 # Examples: "http://foo.com/media/", "/media/".
7 ADMIN_MEDIA_PREFIX = '/media/'
8 
9+# Whether the django development server should serve admin media from the
10+# contrib/admin/media/ directory
11+SERVE_DEFAULT_ADMIN_MEDIA = True
12+
13 # Make this unique, and don't share it with anybody.
14 SECRET_KEY = ''
15 
16Index: django/conf/global_settings.py
17===================================================================
18--- django/conf/global_settings.py      (revision 29)
19+++ django/conf/global_settings.py      (working copy)
20@@ -142,6 +142,10 @@
21 # Examples: "http://foo.com/media/", "/media/".
22 ADMIN_MEDIA_PREFIX = '/media/'
23 
24+# Whether the django development server should serve admin media from the
25+# contrib/admin/media/ directory
26+SERVE_DEFAULT_ADMIN_MEDIA = True
27+
28 # Default e-mail address to use for various automated correspondence from
29 # the site managers.
30 DEFAULT_FROM_EMAIL = 'webmaster@localhost'
31Index: django/core/management.py
32===================================================================
33--- django/core/management.py   (revision 29)
34+++ django/core/management.py   (working copy)
35@@ -1053,7 +1053,10 @@
36         print "Development server is running at http://%s:%s/" % (addr, port)
37         print "Quit the server with %s." % quit_command
38         try:
39-            run(addr, int(port), AdminMediaHandler(WSGIHandler()))
40+            handler = WSGIHandler()
41+            if settings.SERVE_DEFAULT_ADMIN_MEDIA:
42+                handler = AdminMediaHandler(handler)
43+            run(addr, int(port), handler)
44         except WSGIServerException, e:
45             # Use helpful error messages instead of ugly tracebacks.
46             ERRORS = {