Skip to Content
Django 3 Web Development Cookbook - Fourth Edition
book

Django 3 Web Development Cookbook - Fourth Edition

by Aidas Bendoraitis, Jake Kronika
March 2020
Intermediate to advanced
608 pages
17h 17m
English
Packt Publishing
Content preview from Django 3 Web Development Cookbook - Fourth Edition

There's more...

This method works only if each of your environments contains the full Git repository of the project—in some cases, for example, when you use Heroku or Docker for deployments—you don't have access to a Git repository and the git log command in the remote servers. In order to have the STATIC_URL with a dynamic fragment, you have to read the timestamp from a text file—for example, myproject/settings/last-modified.txt—that should be updated with each commit.

In this case, your settings would contain the following lines:

# settings/_base.pywith open(os.path.join(BASE_DIR, 'myproject', 'settings', 'last-update.txt'), 'r') as f:    timestamp = f.readline().strip()STATIC_URL = f'/static/{timestamp}/'

You can make your Git repository ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Django 2 Web Development Cookbook - Third Edition

Django 2 Web Development Cookbook - Third Edition

Jake Kronika, Aidas Bendoraitis

Publisher Resources

ISBN: 9781838987428Supplemental Content