Files
2012-02-21 01:15:00 -05:00

1 line
5.8 KiB
JSON

[{"user_id": 2045, "stars": [], "topic_id": 11176, "date_created": 1299454415.5563531, "message": "This depends on what version of Django you're running. Here are the docs for 1.2 http://docs.djangoproject.com/en/1.2/howto/static-files/, and here's 1.3 http://docs.djangoproject.com/en/dev/howto/static-files/#serving-static-files-in-development. For production, you should use your webserver to serve static files. I deploy using nginx, where I use the location directive (http://wiki.nginx.org/HttpCoreModule#location) with the location of my MEDIA_URL, with a root of MEDIA_ROOT.", "group_id": 81, "id": 282353}, {"user_id": 14492, "stars": [{"date_created": 1299726016.202503, "user_id": 8990}], "topic_id": 11176, "date_created": 1299453980.28813, "message": "So i've read the django-book and the beginner tut at djangoproject.org... but I have never understood how to serve images (and other static files) in the development server. And what are the differences (steps I should take) to serve it when the website is live?", "group_id": 81, "id": 282331}, {"user_id": 927, "stars": [], "topic_id": 11176, "date_created": 1299455439.3028841, "message": "In Apache, you're looking at something pretty similar to Josh's answer: use a <Location /media>DocumentRoot /foobar</Location> to have Apache serve content directly", "group_id": 81, "id": 282411}, {"user_id": 927, "stars": [{"date_created": 1299693169.8177891, "user_id": 6544}], "topic_id": 11176, "date_created": 1299455353.9805889, "message": "I usually structure it like this: https://github.com/acdha/codespeed/blob/master/speedcenter/urls.py#L16", "group_id": 81, "id": 282400}, {"user_id": 927, "stars": [{"date_created": 1299726014.502779, "user_id": 8990}], "topic_id": 11176, "date_created": 1299455519.8390801, "message": "Now, two other notes: you should consider setting up a separate static media server (e.g. media.myproject.com) and simply changing your MEDIA_URL so Django will generate links pointing there instead. That can work with a completely different server such as Amazon or Rackspace's CDN services and is definitely recommend for bigger sites.", "group_id": 81, "id": 282415}, {"user_id": 927, "stars": [{"date_created": 1299693171.121285, "user_id": 6544}], "topic_id": 11176, "date_created": 1299455723.8046291, "message": "The other trick is on https://github.com/acdha/codespeed/blob/master/speedcenter/urls.py#L20 - note that it's set to ignore a leading directory component (e.g. /media/1234/js/bellsandwhistles.js). That allows me to generate URLs based off of the server's start time, a VCS release, etc. which means that caching is a lot easier to manage since the URL can change every time you deploy a new version - that's not essential but it's a good habit to get into, particularly if you are planning to use a CDN or want to enable caching for performance.", "group_id": 81, "id": 282421}, {"user_id": 927, "stars": [], "topic_id": 11176, "date_created": 1299455378.503984, "message": "That way you can set SERVE_STATIC = False in your default settings but enable it independently of DEBUG for testing, benchmarking, etc.", "group_id": 81, "id": 282403}, {"user_id": 214, "stars": [{"date_created": 1299693192.0707059, "user_id": 6544}], "topic_id": 11176, "date_created": 1299456508.0624361, "message": "Note the config @acdha posted is for Django 1.2 - if you're using 1.3rc static file serving in development is built in, nothing extra in urls.py is needed (and you no longer want to be putting your static assets in MEDIA_ROOT, rather in apps' static/ subdirs and perhaps a project-wide entry in STATICFILES_DIRS).", "group_id": 81, "id": 282559}, {"user_id": 14492, "stars": [], "topic_id": 11176, "date_created": 1299458531.5239191, "message": "a lot of info for a noob like me to absorb... lol! thank you all :)", "group_id": 81, "id": 283005}, {"user_id": 14492, "stars": [], "topic_id": 11176, "date_created": 1299458777.82323, "message": "actually MEDIA_ROOT i get.. but MEDIA_URL and ADMIN_MEDIA_PREFIX not so much.", "group_id": 81, "id": 283057}, {"user_id": 14492, "stars": [], "topic_id": 11176, "date_created": 1299459489.6814909, "message": "sorry if I'm not getting it... as I said, I'm a noob, and I believe the current documentation (on this subject at least) is not explained enough for my limited species... :D", "group_id": 81, "id": 283168}, {"user_id": 14492, "stars": [{"date_created": 1299693206.213968, "user_id": 6544}], "topic_id": 11176, "date_created": 1299460161.2432001, "message": "Ok, I think I got it (at least on the development). @acdha input really helped, I also checked this out http://www.muhuk.com/2009/05/serving-static-media-in-django-development-server/", "group_id": 81, "id": 283207}, {"user_id": 14492, "stars": [], "topic_id": 11176, "date_created": 1299458558.4505191, "message": "should I expect any troubles if I update my current Django Version (1.2.5) to 1.3?", "group_id": 81, "id": 283009}, {"user_id": 14492, "stars": [], "topic_id": 11176, "date_created": 1299458712.9286549, "message": "I believe the major trouble I have is not understanding what the MEDIA_ROOT, MEDIA_URL and ADMIN_MEDIA_PREFIX mean in settings.py. What are the differences?", "group_id": 81, "id": 283044}, {"user_id": 927, "stars": [], "topic_id": 11176, "date_created": 1299461638.280061, "message": "@carljm Good point - we're so close to 1.3 release that it's probably time to stop recommending 1.2", "group_id": 81, "id": 283317}, {"user_id": 6396, "stars": [], "topic_id": 11176, "date_created": 1299529914.3552859, "message": "@gcmartinelli Check this out, it's a run down of what *might* break. http://docs.djangoproject.com/en/dev/releases/1.3/#backwards-incompatible-changes-in-1-3", "group_id": 81, "id": 290730}, {"user_id": 14492, "stars": [], "topic_id": 11176, "date_created": 1299650065.967, "message": "@djm thanks :)", "group_id": 81, "id": 302246}]