Fwd: Feature request : Load signals automatically

2021-09-14 Thread Roxane Bellot
Hi guys !

First of all, i’m new here, so if this issue has already been discussed or
if here is not the place to talk about it (I also opened a forum post
<https://forum.djangoproject.com/t/load-signals-automatically/9666>) please
don’t hesitate to tell me. Also, please be aware English is not my first
language.

I would want to discuss about signals and how they are loaded in Django.

Very often, i create my signals.py, write my signal and wonder for a while
why it does not work. Of course, the file is not imported and so never even
read by python !
So i create an apps.py, on this template :

from django.apps import AppConfig

class CustomAppConfig(AppConfig):
name = "app.subapp"

def ready(self):
import app.subapp.signals


I would like to sugest importing signals.py automatically at app loading
(maybe django.apps.config.AppConfig.ready() ?)

*Pros*

   - no more wandering for hours what is the problem here
   - no more boilerplate apps.py everywhere

*Cons*

   - file with signals would have to be named signals.py
   - maybe some rely on the file being imported when they decided ? (don’t
   see a use case here, specially when loading signals does not equals
   activating them)

*Alternatives*

If loading (and so activating) signals is too mush of a change, maybe
others solutions will fix my problem. For know, all I can think of :

   - Log if a signals.py file is detected but the AppConfig is not
   overriden (but we would not know if imported elsewhere)
   - Log how many signals are detected for the app (but from a dozen apps
   the log will be too heavy to be read)
   - not really an alternative, but the loading could be conditionnal to a
   project-wide setting

i would like to know if this would benefits others (I think so) and if it
is worthy of filing an Issue (as a developper I may find time to dev on it
if needed)


Looking forward to reading from you,

Roxane Bellot

-- 
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 django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAAvJ%2BFzx%3DFZ01BvBhEtH8SOZQA3imM4q3j1FNA7EF6ec1BKrPA%40mail.gmail.com.


Re: Feature Request: Provide an option to disable static files caching during development

2021-10-23 Thread Roxane Bellot
Hi

Wouldn't the setting "CACHE_MIDDLEWARE_SECONDS" do what you are looking for 
?

Regards,


Le vendredi 22 octobre 2021 à 15:53:44 UTC+2, Bharat Chauhan a écrit :

> Really, no one is interested in making the developer experience a little 
> less frustrating?
>
> It's literally two lines of code and will eventually save hours trying to 
> refresh the cache by opening dev tools, 
> which, btw, isn't even possible on mobile.
>
> Besides, Django's dev server is not meant to be used in production. So why 
> even care about caching?
> On Tuesday, September 28, 2021 at 10:49:06 AM UTC+5:30 laym...@gmail.com 
> wrote:
>
>> I'm +1 on this.
>>
>> In my experience teaching Django at university, this always confuses 
>> students: "why are my changes not reflected in the browser?"
>>
>> Having static files caching disabled when DEBUG=True would be very 
>> useful. Thanks for bringing this up!
>>
>> Sage
>>
>> On Monday, 27 September 2021 at 20:17:35 UTC+7 Bharat Chauhan wrote:
>>
>>> Hello,
>>>
>>> I recently opened a ticket (#33148 
>>> ) but it was closed as 
>>> duplicate of (#32891 ) 
>>> which itself is marked "wontfix".
>>>
>>> The reasoning provided by Carlton Gibson for this is:
>>>
>>> > *I don't think this is the right approach. As far as I can see the 
>>> browser behaviour is correct and as desired, s**erving static assets 
>>> from the browser cache when possible.*
>>>
>>> At least while DEBUG is True, I see no harm in setting `Cache-Control: 
>>> max-age=0` header.
>>>
>>> This will allow browsers to cache the files while forcing them to 
>>> revalidate cache using the If-Modified-Since header. This way, Django can 
>>> serve updated files if they get modified or return a 304 response in which 
>>> case browsers will use the cached file (conforming to Carlton's comment 
>>> about using browser cache when possible).
>>>
>>> This will aid in development as we now have to open the browser's 
>>> network tab and disable the cache to refresh static files. In Mobile, 
>>> disabling cache is not possible, so we have to test in Incognito Mode. It's 
>>> a frustrating development experience.
>>>
>>> Thank you.
>>>
>>

-- 
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 django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/3ad5b02b-0f48-40d3-ba46-f278dd51c0b9n%40googlegroups.com.