Quantcast

NEW Feature: Collect static order of directories searched. Possible upgrade inside FileSystemFinder.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

NEW Feature: Collect static order of directories searched. Possible upgrade inside FileSystemFinder.

Radosław Orłowski
Right now I'm working with Django 1.8.17 and What I'm trying to acomplish is simple override of static files.

STATICFILES_DIRS = (
        str(os.path.abspath(os.path.join(SITE_ROOT, 'static_new'))),
        str(os.path.abspath(os.path.join(SITE_ROOT, 'static'))),
)

STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)

my thinking:
I have to sites that need different logo file.

Both directories static and static_new have images/logo.png, but this file is different.

I need to add logo from static_new and load rest of content from static (js, css. etc)
This would allow me to create folders with statics -- per site without changing urls and templates, just collect static would take images from another dir, other changes are made with  django.contrib.sites.models.get_current_site
Collect static works with first found but I have no way to define 'seach here first behavior'. Also development static and collectstatic don't seem to search for those files with same order (also I find them both unstable as once in a while logo is loaded from static_new and mostly from static)


Expected behavior:
when adding new folder to STATICFILES_FINDERS, I can somehow define order of folders static file finder will go through searching for this item either as alphabetic order or by explicit order. ('static',2),('static_new',1)
second behavior is similar to list_display and fieldsets in admin views, I would love to introduce here something like that.


Discussion open.

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/b5fa5a9a-7b1f-4339-96de-5b9e4b1771af%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: NEW Feature: Collect static order of directories searched. Possible upgrade inside FileSystemFinder.

Tim Graham-2
Hi, I'm surprised if the search behavior is nondeterministic rather than searching STATICFILES_DIRS in order. If that's really the case, it seems like a bug. Can you point to the code that causes the nondeterminism?

On Friday, March 10, 2017 at 7:35:25 AM UTC-5, Radosław Orłowski wrote:
Right now I'm working with Django 1.8.17 and What I'm trying to acomplish is simple override of static files.

STATICFILES_DIRS = (
        str(os.path.abspath(os.path.join(SITE_ROOT, 'static_new'))),
        str(os.path.abspath(os.path.join(SITE_ROOT, 'static'))),
)

STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)

my thinking:
I have to sites that need different logo file.

Both directories static and static_new have images/logo.png, but this file is different.

I need to add logo from static_new and load rest of content from static (js, css. etc)
This would allow me to create folders with statics -- per site without changing urls and templates, just collect static would take images from another dir, other changes are made with  django.contrib.sites.models.get_current_site
Collect static works with first found but I have no way to define 'seach here first behavior'. Also development static and collectstatic don't seem to search for those files with same order (also I find them both unstable as once in a while logo is loaded from static_new and mostly from static)


Expected behavior:
when adding new folder to STATICFILES_FINDERS, I can somehow define order of folders static file finder will go through searching for this item either as alphabetic order or by explicit order. ('static',2),('static_new',1)
second behavior is similar to list_display and fieldsets in admin views, I would love to introduce here something like that.


Discussion open.

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/86d68df8-38e0-4dad-ab93-6d12e1d2eeba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: NEW Feature: Collect static order of directories searched. Possible upgrade inside FileSystemFinder.

René Fleschenberg
In reply to this post by Radosław Orłowski
Hi Radosław,

On 03/10/2017 11:49 AM, Radosław Orłowski wrote:

> Right now I'm working with Django 1.8.17 and What I'm trying to
> acomplish is simple override of static files.
>
> STATICFILES_DIRS = (
>         str(os.path.abspath(os.path.join(SITE_ROOT, 'static_new'))),
>         str(os.path.abspath(os.path.join(SITE_ROOT, 'static'))),
> )
>
> STATICFILES_FINDERS = (
>     'django.contrib.staticfiles.finders.FileSystemFinder',
>     'django.contrib.staticfiles.finders.AppDirectoriesFinder',
> )
>
> my thinking:
> I have to sites that need different logo file.
>
> Both directories static and static_new have images/logo.png, but this
> file is different.
>
> I need to add logo from static_new and load rest of content from static
> (js, css. etc)


You mentioned that you have two sites. Are you using the sites
framework? Then you should have a separate settings module for each
site, so you can just give them different settings:


```
# settings_site1.py
# site1 only uses files from ``static``.
SITE_ID = 1
STATIC_ROOT = '/var/static/site1'
STATICFILES_DIRS = (
    os.path.abspath(os.path.join(SITE_ROOT, 'static')),
)


# settings_site2.py
# site2 uses files from ``static_new``, and falls back to ``static``
SITE_ID = 2
STATIC_ROOT = '/var/static/site2'
STATICFILES_DIRS = (
    os.path.abspath(os.path.join(SITE_ROOT, 'static_new')),
    os.path.abspath(os.path.join(SITE_ROOT, 'static')),
)



Regards,
René

--
René Fleschenberg

--
You received this message because you are subscribed to the Google Groups "Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/933e0d82-b0f8-9676-05bc-0d2ab8a5d974%40fleschenberg.net.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: NEW Feature: Collect static order of directories searched. Possible upgrade inside FileSystemFinder.

Luke Plant-2
In reply to this post by Tim Graham-2

Like Tim, I'm surprised if there is non-determinism in the order here - a quick look at the code shows the search is in the order specified in  STATICFILES_DIRS. Is it possible you are encountering browser caching effects, perhaps triggered by accessing both sites on 'localhost' locally?


Luke

On 10/03/17 16:35, Tim Graham wrote:
Hi, I'm surprised if the search behavior is nondeterministic rather than searching STATICFILES_DIRS in order. If that's really the case, it seems like a bug. Can you point to the code that causes the nondeterminism?

On Friday, March 10, 2017 at 7:35:25 AM UTC-5, Radosław Orłowski wrote:
Right now I'm working with Django 1.8.17 and What I'm trying to acomplish is simple override of static files.

STATICFILES_DIRS = (
        str(os.path.abspath(os.path.join(SITE_ROOT, 'static_new'))),
        str(os.path.abspath(os.path.join(SITE_ROOT, 'static'))),
)

STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)

my thinking:
I have to sites that need different logo file.

Both directories static and static_new have images/logo.png, but this file is different.

I need to add logo from static_new and load rest of content from static (js, css. etc)
This would allow me to create folders with statics -- per site without changing urls and templates, just collect static would take images from another dir, other changes are made with  django.contrib.sites.models.get_current_site
Collect static works with first found but I have no way to define 'seach here first behavior'. Also development static and collectstatic don't seem to search for those files with same order (also I find them both unstable as once in a while logo is loaded from static_new and mostly from static)


Expected behavior:
when adding new folder to STATICFILES_FINDERS, I can somehow define order of folders static file finder will go through searching for this item either as alphabetic order or by explicit order. ('static',2),('static_new',1)
second behavior is similar to list_display and fieldsets in admin views, I would love to introduce here something like that.


Discussion open.
--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/86d68df8-38e0-4dad-ab93-6d12e1d2eeba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/213566d4-3cf8-2e7e-e16d-4d48c82837f5%40cantab.net.
For more options, visit https://groups.google.com/d/optout.
Loading...