Re: Location of non-app-specific static files?

40 views
Skip to first unread message

Elena Williams

unread,
Nov 3, 2012, 11:23:11 PM11/3/12
to django...@googlegroups.com
Hi Ryan,

I'm not sure if it helps but not long ago I found this by Simon Willison on Quora:

Cheers,
Elena :)

---
Elena :)
@elequ
04022 90172



On Sun, Nov 4, 2012 at 10:23 AM, Ryan <ryan.os...@gmail.com> wrote:
Hi,

I have been wondering where people put their non-app-specific static files in their django projects?  For example, the base css file that applies to all pages across the project or perhaps the jquery file?

Currently I have the following structure:

.
├── app
│   ├── __init__.py
│   ├── models.py
│   ├── static
│   │   └── app
│   │       ├── css
│   │       ├── img
│   │       └── js
│   ├── templates
│   │   └── app
│   ├── tests.py
│   └── views.py
├── manage.py
└── mysite
    ├── __init__.py
    ├── settings.py
    ├── static
    ├── templates
    ├── urls.py
    └── wsgi.py

My STATIC_ROOT setting points to the ./mysite/static directory as this is where I would like collectstatic to dump all the static files for deployment, however this is also the obvious place (for me anyway) to place non-app-specific static files as they apply to the project as a whole like the templates directory at this level.

Does any one have any input on this?

Thanks,

Ryan

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/4H39KqmnTugJ.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Stodge

unread,
Nov 4, 2012, 9:38:09 AM11/4/12
to django...@googlegroups.com
I have two project static directories, STATIC and STATIC_FILES. STATIC contains non-app specific static files. STATIC_FILES is where static files are "collected".

Xavier Ordoquy

unread,
Nov 4, 2012, 10:12:58 AM11/4/12
to django...@googlegroups.com
Hi,

One thing I've seen - and adopted - is to have one application that contains the static files.
It looks like:

└── mysite
    ├── __init__.py
    ├── settings.py
    ├── theme
        ├── __init__.py
        ├── models.py (empty file)
        └── static
    ├── static
    ├── templates
    ├── urls.py
    └── wsgi.py

Then you add the application in your INSTALLED_APPS and you're done.

Regards,
Xavier Ordoquy,
Linovia.

Fred Stluka

unread,
Nov 4, 2012, 8:33:54 PM11/4/12
to django...@googlegroups.com
Yeah, I do the same with STATIC and COLLECTED_STATIC.

--Fred
Fred Stluka -- mailto:fr...@bristle.com -- http://bristle.com/~fred/
Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
Open Source: Without walls and fences, we need no Windows or Gates.

Joni Bekenstein

unread,
Nov 5, 2012, 8:58:19 AM11/5/12
to django...@googlegroups.com
Check this out: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#staticfiles-dirs

I put a static folder in my project root where I put all the project specific (ant not app specific) static files. The folder's path is then added to STATICFILES_DIRS.

But note that this static folder is different than STATIC_ROOT folder where the collectstatic management command collects all static files for deployment (https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-STATIC_ROOT)

I separate them because the first one is checked into version control, while the second one is not.

On Monday, November 5, 2012 5:53:33 AM UTC-3, Ryan wrote:
That is not a bad idea as everything that is project specific, but not app specific, would live in one place.

Thanks,

Ryan
Reply all
Reply to author
Forward
0 new messages