Opened 3 years ago

Closed 3 years ago

#18111 closed Uncategorized (invalid)

Django autoreload doesn't work for forms.py or tests.py in my app (but does for models.py)

Reported by: stu.axon@… Owned by: nobody
Component: Uncategorized Version: 1.4
Severity: Normal Keywords: autoreload
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I've created a django app that I use within my site. When I change it's models.py reload happens, however for forms.py and tests.py it does not.

Change History (4)

comment:1 Changed 3 years ago by stu.axon@…

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Note:

If I open autoreload.py and put the following code

        if filename.endswith("models.py"):
            print 'MODEL: ', filename
        elif filename.endswith("forms.py"):
            print 'FORM: ', filename

I can see all my and djangos models, also forms it' uses, but none from my app:

MODEL:  ..../python2.7/site-packages/django/contrib/staticfiles/models.py
FORM:  ..../python2.7/site-packages/django/contrib/auth/forms.py
MODEL:  ..../python2.7/site-packages/compressor/models.py
MODEL:  ..../python2.7/site-packages/django/contrib/messages/models.py
MODEL:  ..../python2.7/site-packages/django/contrib/sites/models.py
MODEL:  ~/projects/jpc/git/MY_SITE/MY_APP/calendar_models.py
MODEL:  ..../python2.7/site-packages/django/contrib/formtools/models.py
MODEL:  ..../python2.7/site-packages/django/contrib/auth/models.py
FORM:  ..../python2.7/site-packages/django/forms/forms.py
MODEL:  ..../python2.7/site-packages/django/contrib/admin/models.py
MODEL:  ~/projects/jpc/git/MY_SITE/MY_APP/models.py
MODEL:  ..../python2.7/site-packages/django/contrib/contenttypes/models.py

MODEL:  ..../python2.7/site-packages/debug_toolbar/models.py
MODEL:  ..../python2.7/site-packages/django/forms/models.py
MODEL:  ..../python2.7/site-packages/django/contrib/sessions/models.py
FORM:  ..../python2.7/site-packages/django/contrib/admin/forms.py

comment:2 Changed 3 years ago by stu.axon@…

Putting the following code into MY_APP/init.py works as a workaround, although doesn't seem ideal:

try:
  import forms
except:
  pass

comment:3 Changed 3 years ago by stu.axon@…

Last bit of info for now - here's the (not recommended) init.py I came up with to reload forms and tests automatically:

try:
    from django.conf import settings
    if settings.DEBUG:
        import forms, tests
except:
    pass

comment:4 Changed 3 years ago by aaugustin

  • Resolution set to invalid
  • Status changed from new to closed

By design, the development server only reloads code that it's actually using.

If forms.py isn't used, what's the point in reloading the development server when it's changed?

Note: See TracTickets for help on using tickets.
Back to Top