-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add autoreload file tracking options setting #7791
Conversation
Why does the development server have to restart for changes in non-Python files? |
I have View functions that reads in HTML/Javascript/SQL. If I edit these files, the development server still serves operates on & serves the older HTML/Javascript/SQL. |
It sounds like the browser might be caching those files. I don't think adding a new setting here is going to be accepted. |
It's not the browser that is caching the file... the actual server doesn't restart automatically |
Right now, the development server restarts whenever you edit a Python file. This also makes sure it restarts whenever you edit additional specific files. |
I'd suggest to write to django-users and explain the use case a bit more. If others think a feature must be added to Django, then please create a ticket. Thanks! |
I tried to create a ticket, but forgot my password, and couldn't find a password reset form. Is there a password reset option somewhere? My email is mozumder@futureclaw.com |
By the way, approval for all new settings also needs to go through the django-developers mailling list. You've not made it clear why the server is caching non-Python files. Perhaps a code snippet would help explain your use case. |
OK sent an email to django-developers. |
OK here is some example code snippet where I load prepared SQL statements: class FastDetailView(DetailView,FastView):
c = connection.cursor()
SQL_VIEW_DIRS = {
'fashion': (
'include/sql/materializedviews/headlines',
'include/sql/materializedviews/latestCollections',
'include/sql/materializedviews/allSeasons',
'include/sql/materializedviews/fullSeason',
'include/sql/materializedviews/gallery',
'include/sql/materializedviews/indexView',
'include/sql/materializedviews/cover',
'include/sql/materializedviews/latestSeasonView',
'include/sql/materializedviews/seasonView',
'include/sql/materializedviews/collectionView',
'include/sql/materializedviews/latestCollectionsJSON',
'include/sql/materializedviews/collectionCardJSON',
'include/sql/materializedviews/indexJSON',
'include/sql/materializedviews/categoryJSON',
'include/sql/materializedviews/articleJSON',
'include/sql/triggers/globals',
'include/sql/triggers/brand',
'include/sql/triggers/collection',
'include/sql/triggers/collectionlookassignment',
'include/sql/triggers/cover',
'include/sql/triggers/look',
'include/sql/triggers/photo',
'include/sql/triggers/season',
'include/sql/triggers/fashion_headlinesviewmat',
'include/sql/triggers/fashion_latestcollectionsviewmat',
'include/sql/triggers/fashion_allseasonsviewmat',
'include/sql/triggers/fashion_fullseasonviewmat',
'include/sql/triggers/fashion_galleryviewmat',
'include/sql/triggers/fashion_coverviewmat',
'include/sql/triggers/fashion_indexviewmat',
'include/sql/triggers/fashion_latestseasonviewmat',
'include/sql/triggers/fashion_seasonviewmat',
'include/sql/triggers/fashion_collectionviewmat',
'include/sql/triggers/fashion_collectioncardjsonviewmat',
),
'analytics': (
'include/sql/analytics',
),
}
MATERIALIZED_VIEWS = True
@classmethod
def prepare_db_queries(self):
logger.info('Reading fashion prepared SQL statements')
cursor = connection.cursor()
for sql_view_dir in SQL_VIEW_DIRS['fashion']:
file_name = sql_view_dir + '/prepare.sql'
try:
with open(file_name, 'r') as file:
sql_prepare=file.read().strip()
if sql_prepare:
cursor.execute(sql_prepare)
except (OSError, IOError) as e:
pass
except e:
logger.info('Error reading SQL file: %s' % file_name)
raise e
if MATERIALIZED_VIEWS:
file_name = sql_view_dir + '/prepare_materialized.sql'
try:
with open(file_name, 'r') as file:
sql_prepare=file.read().strip()
if sql_prepare:
cursor.execute(sql_prepare)
except (OSError, IOError) as e:
pass
except e:
logger.info('Error reading SQL file: %s' % file_name)
raise e It basically reads SQL from a separate list of files that I use in my view function, and executes those SQL files. If I edit these SQL files, it won't restart the development server. |
Right now, Django only tracks Python module files for autoreload during development. As a project starts to include more custom files, such as Javascript, SQL, Makefiles, etc.., the autoreload function doesn't apply to these.
With this pull request, we can add a manual list of files to track for autoreload.
In your project's settings.py file, assign a variable TRACK_FILES containing a list of full file paths to track. This will track files to autoreload the development run server as these files are updated.