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

Reply via email to