I'm trying to add an extra directory for each app that will contain 
Javascript/CSS files. I created a custom storage.py in my app containing a 
copy of the code from Django's AppDirectoriesFinder class, but I changed 
source_dir from "static" to "catalog". I'll include the Django code with 
the modified source_dir so no-one has to check the source code:

class AppCatalogStorage(FileSystemStorage):
    """
    A file system storage backend that takes an app module and works
    for the ``catalog`` directory of it.
    """
    prefix = None
    source_dir = 'catalog'  <------- changed, was 'static'


    def __init__(self, app, *args, **kwargs):
        """
        Returns a static file storage if available in the given app.
        """
        # app is the actual app module
        mod = import_module(app)
        mod_path = os.path.dirname(upath(mod.__file__))
        location = os.path.join(mod_path, self.source_dir)
        super(AppCatalogStorage, self).__init__(location, *args, **kwargs)



I added this to my settings file:

    STATICFILES_STORAGE = (

        'myapp.storage.AppCatalogStorage',
        'django.contrib.staticfiles.storage.StaticFilesStorage'
    )


My understanding here is that I can then do:

(Assuming my app name is fred)

fred/catalog/js/someJavascript.js
fred/catalog/css/someStylesheet.css


I also assumed they would then be accessible as:

/static/fred/js/someJavascript.js
/static/fred/css/someStylesheet.css


However, neither file is available at the expected URL. Did I misunderstand 
something?

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/46fe4111-0cfc-4515-9a5c-62fc292de8f2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to