Advertisement
Guest User

Untitled

a guest
Jul 31st, 2014
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.57 KB | None | 0 0
  1. mysite/
  2. __init__.py
  3. MySiteDB
  4. manage.py
  5. settings.py
  6. urls.py
  7. myapp/
  8. __init__.py
  9. admin.py
  10. models.py
  11. test.py
  12. views.py
  13. templates/
  14. index.html
  15.  
  16. <head>
  17. <title>Degree Planner</title>
  18. <script type="text/javascript" src="/scripts/JQuery.js"></script>
  19. <script type="text/javascript" src="/media/scripts/sprintf.js"></script>
  20. <script type="text/javascript" src="/media/scripts/clientside.js"></script>
  21. </head>
  22.  
  23. (r'^admin/', include(admin.site.urls)),
  24. (r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': 'media'})
  25. (r'^.*', 'mysite.myapp.views.index'),
  26.  
  27. TypeError at /admin/auth/
  28. 'tuple' object is not callable
  29.  
  30. MEDIA_ROOT = '/media/'
  31. MEDIA_URL = 'http://127.0.0.1:8000/media'
  32.  
  33. ROOT_PATH = os.path.normpath(os.path.dirname(__file__))
  34.  
  35. (r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': os.path.join(settings.ROOT_PATH, 'site_media')}),
  36.  
  37. <script type="text/javascript" src="/media/JQuery.js"></script>
  38. <script type="text/javascript" src="/media/sprintf.js"></script>
  39. <script type="text/javascript" src="/media/clientside.js"></script>
  40.  
  41. mysite/
  42. site_media/
  43. JQuery.js
  44. sprintf.js
  45. clientside.js
  46. __init__.py
  47. settings.py
  48. manage.py
  49. -- etc
  50. myapp/
  51. -- app files, etc
  52.  
  53. Page not found: /media/sprintf.js
  54.  
  55. mysite/
  56. site_media/
  57. css/
  58. js/
  59. images/
  60. ...
  61.  
  62. ROOT_PATH = os.path.normpath(os.path.dirname(__file__))
  63.  
  64. url(r'^media/(?P<path>.*)$', "django.views.static.serve", {'document_root':
  65. os.path.join(settings.ROOT_PATH, 'site_media')})
  66.  
  67. mysite.com/
  68. media/ - User media, this goes in settings.MEDIA_ROOT
  69. static/ - This is your static content folder
  70. css/
  71. js/
  72. images/
  73. templates/
  74. project/ - This is your Django project folder
  75. __init__.py
  76. manage.py
  77. settings.py
  78. myapp/
  79. __init__.py
  80. ...files..py
  81.  
  82. (r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': os.getenv('STATIC_DIR')})
  83.  
  84. if settings.DEBUG:
  85. urlpatterns += patterns('',
  86. (r'^media/(?P<path>.*)$', 'django.views.static.serve',
  87. {'document_root': settings.MEDIA_ROOT}),
  88. )
  89.  
  90. # Absolute path to the directory that holds media.
  91. # Example: "/home/media/media.lawrence.com/"
  92. MEDIA_ROOT = '/srv/nginx/<sitename>/media/'
  93.  
  94. # URL that handles the media served from MEDIA_ROOT. Make sure to use a
  95. # trailing slash if there is a path component (optional in other cases).
  96. # Examples: "http://media.lawrence.com", "http://example.com/media/"
  97. MEDIA_URL = 'http://127.0.0.1:8000/media/'
  98.  
  99. TEMPLATE_CONTEXT_PROCESSORS = (
  100. # I've taken out my other processors for this example
  101. "django.core.context_processors.media",
  102. )
  103.  
  104. <link rel="stylesheet" href="{{ MEDIA_URL }}css/form.css" />{% endblock %}
  105.  
  106. /srv/nginx/<sitename>
  107. /media <-- MEDIA_ROOT/MEDIA_URL points to here
  108. /css
  109. base.css
  110. form.css
  111. /img
  112. /js
  113.  
  114. import os
  115. PROJECT_PATH = os.path.realpath(os.path.dirname(__file__))
  116. MEDIA_ROOT = os.path.join(PROJECT_PATH, 'site_media')
  117. MEDIA_URL = '/media/'
  118.  
  119. /media
  120. favicon.ico
  121. robots.txt
  122. /upload # user uploaded files
  123. /js # global js files like jQuery
  124. /main_app
  125. /js
  126. /css
  127. /img
  128. /other_app
  129. /js
  130. /css
  131. /img
  132.  
  133. import os
  134. import annoying
  135.  
  136. MEDIA_ROOT = os.path.join(os.path.dirname(__file__), "media")
  137. MIDDLEWARE_CLASSES = (
  138. 'annoying.middlewares.StaticServe',
  139. #...
  140. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement