I think this is a bug. When using the default settings.py, the development environment runs fine.
If I change STATIC_URL, nothing else, it doesn't serve static files when starting the server. I think it's a bug, but I don't know what the intended behavior is. I'd think that the dev server should read the settings module, then serve the static directoriess to whatever URL is specified in STATIC_URL, so no matter what STATIC_URL is it should work. matt On Wed, Feb 15, 2012 at 3:56 PM, Matthew Hanson <[email protected]> wrote: > Ariel thanks a lot, > > I think I mostly understand Django's media handling, as I've used > Django prior to GeoNode, and don't have a problem with production > deployment. What I'm having a hard time with now is serving the > static files in the development environment. Now to be clear, I can > serve static files fine using the default setting for STATIC_URL. > But if I change STATIC_URL to anything else, it fails to work. Even > if I just add a prefix of http://localhost:8000/ it fails to work. > (in production we may be serving static files from a different > machine) > > STATIC_URL = '/media/' # original setting, works fine > > STATIC_URL = '/static/' # fails > STATIC_URL = 'http://localhost:8000/static/ # fails > > The paster host seems to be set up to serve files at the original > setting location (/media/), and I can't find where to change it. Or > maybe there's something else going on here. > > I also see you included this in your settings: > > STATICFILES_STORAGE = 'staticfiles.storage.StaticFilesStorage' > > which was removed from the settings file in 1.1 Is it required ? > > The relevant section of my settings file is pasted here, and it's > currently configured to work properly, but I would like to change the > names of some directories as well as be able to add an ASSETS_URL > prefix (to point to a different machine) > > > ########################################################### > # Locations of things > ########################################################### > > # Assets include media, static, admin, etc - any static resources > ASSETS_ROOT = os.path.join(PROJECT_ROOT,'media/') #'/var/www/geonode/' > #ASSETS_URL = 'http://localhost:8000/media/' > ASSETS_URL = "/media/" > > # Absolute path to the directory that holds media. > # Example: "/home/media/media.lawrence.com/" > MEDIA_ROOT = os.path.join(ASSETS_ROOT,'media/') > # trailing slash if there is a path component (optional in other cases). > # Examples: "http://media.lawrence.com", "http://example.com/media/" > MEDIA_URL = ASSETS_URL + 'media/' > GEONODE_UPLOAD_PATH = MEDIA_ROOT > > # Absolute path to the directory that holds static files like app media. > # Example: "/home/media/media.lawrence.com/apps/" > STATIC_ROOT = os.path.join(ASSETS_ROOT,'static/') > # Additional directories which hold static files > STATICFILES_DIRS = ( > os.path.join(PROJECT_ROOT, 'media'), > ) > # URL that handles the static files like app media. > # Example: "http://media.lawrence.com" > #STATIC_URL = ASSETS_URL + 'static/' > STATIC_URL = '/media/' > GEONODE_CLIENT_LOCATION = STATIC_URL + "static/" > > # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a > # trailing slash. > # Examples: "http://foo.com/media/", "/media/". > ADMIN_MEDIA_PREFIX = os.path.join(ASSETS_URL,'admin/') > > > On Wed, Feb 15, 2012 at 3:09 PM, Ariel Nunez <[email protected]> wrote: >> Mathew, >> >> I understand how daunting media handling is for Django and especially >> in GeoNode with the additional GEONODE_CLIENT_LOCATION, there is a >> reason for each of those settings but I won't go in detail now (can >> provide links later if needed). >> >> Here is how I configure the settings file in my development projects >> so they are development and production friendly: >> >> MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'static', 'uploaded') >> >> MEDIA_URL = '/uploaded/' >> STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static') >> STATIC_URL = '/static/' >> GEONODE_UPLOAD_PATH = MEDIA_ROOT + 'geonode' >> #GEONODE_CLIENT_LOCATION = 'http://localhost:8080/' >> GEONODE_CLIENT_LOCATION = STATIC_URL + 'geonode/' >> ADMIN_MEDIA_PREFIX = STATIC_URL + 'admin/' >> >> STATICFILES_STORAGE = 'staticfiles.storage.StaticFilesStorage' >> >> # Additional directories which hold static files >> STATICFILES_DIRS = [ >> os.path.join(PROJECT_ROOT, 'media'), >> os.path.join(GEONODE_ROOT, "media"), >> ] >> >> # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use >> a >> # trailing slash. >> # Examples: "http://foo.com/media/", "/media/". >> ADMIN_MEDIA_PREFIX = os.path.join(STATIC_URL, "admin/") >> >> >> For deployment you need to use the: `geonode collectstatic` static >> command (pass it a -v0 flag if you have an error related to printing) >> and that will take care of putting the static files in the right dir >> (usually /var/www/geonode/static ). >> >> MEDIA_* are for user submitted files >> STATIC_* are for things like css and js >> GEONODE_CLIENT_URL is just there to be able to point to a development >> version of geonode-client, usually maps to a place under STATIC_URL. >> >> In my urls.py I do: >> >> from staticfiles.urls import staticfiles_urlpatterns >> >> # Extra static file endpoint for development use >> if settings.SERVE_MEDIA: >> urlpatterns += >> [url(r'^static/thumbs/(?P<path>.*)$','django.views.static.serve',{ >> 'document_root' : settings.STATIC_ROOT + "/thumbs" >> })] >> urlpatterns += >> [url(r'^uploaded/(?P<path>.*)$','django.views.static.serve',{ >> 'document_root' : settings.MEDIA_ROOT >> })] >> >> urlpatterns += staticfiles_urlpatterns() >> >> Hope it helps, >> Ariel. >> >> On Wed, Feb 15, 2012 at 1:18 PM, Matthew Hanson >> <[email protected]> wrote: >>> Hello there, >>> >>> We've been starting to work with GeoNode here, and this is my first >>> post, although I met some of you at FOSS4G this year. I'd introduce >>> our project, but right now there is no public site. We're using >>> GeoNode in a multi-site configuration, which means utilizing the >>> Django Sites framework and tweaking GeoNode to use it. I've got a >>> basic multi-site config running in Production on Apache, and am trying >>> to get my development environment matched up, however paster, and >>> static and media URL's are giving me some heartburn (I'm using >>> family-friendly language here). >>> >>> The plethora of file location variables is rather daunting: >>> STATIC_URL, STATICFILES_DIR, MEDIA_URL, GEONODE_CLIENT_LOC, ADMIN, >>> etc. and certainly has caused me lots of confusion. The problem I >>> was having is when I changed STATIC_URL, my development server was >>> unable to find the static files. With Apache I've got no problem as >>> it's easy enough to change to whatever I wish. But with paster I'm >>> unable to make any sense out of the shared/dev-paste.ini file. The >>> syntax in it doesn't match up with the paster online documentation. >>> To be more specific, the app:static config block doesn't set >>> document_root like the documentation says must be provided. It >>> instead gives >>> >>> egg=GeoNode >>> resource_name=GeoNode/static >>> >>> There's reference to resource_name in paste.urlparser, but no examples >>> of a configuration file using the syntax above. Obviously paster is >>> setting the server settings somewhere, but I can't for the life of me >>> figure out where. I just want to be able to change some of my >>> settings variables for locations of things, but seems like the >>> development environment has hardcoded some things somewhere. >>> >>> Any insight? >>> >>> Thanks in advance, >>> >>> Matthew Hanson >>> Applied GeoSolutions >>> http://www.appliedgeosolutions.com
