Sharing templates across multiple projects

177 views
Skip to first unread message

JHeasly

unread,
Mar 5, 2015, 9:24:04 PM3/5/15
to django...@googlegroups.com
Hello —

I'm looking for any blogposts/best practices for deploying a common set of templates across multiple Django projects.

My initial impulse is to just make a master Github repo of the template and pull it into each of the projects. Are there better approaches?

TIA,
John

Simon Charette

unread,
Mar 6, 2015, 2:08:26 PM3/6/15
to django...@googlegroups.com
Hi John,

I suggest you put the templates you want to share in a location accessible by your multiple projects and add this directory to your TEMPLATE_DIRS setting.

Make sure you have 'django.template.loaders.filesystem.Loader' in your TEMPLATE_LOADERS setting.

You could also make a third-party Django application only containing a "templates" directory and install it in all you projects and use the 'django.template.loaders.app_directories.Loader' loader.

Simon

Ilya Kazakevich

unread,
Mar 6, 2015, 2:34:33 PM3/6/15
to django...@googlegroups.com
I like Simon's ideas about shared location and separate app (Django encourages us to use apps to share anything), but you also may share them on VCS level. SVN supports "external" checkout, in git you may add one repository to another. 

\project1\templates\shared_temps
\project2\templates\shared_temps

"shared_temps" in both cases is just a repository (folder with .git subfolder). So, you commit in one folder, push, and pull in all other projects.

JHeasly

unread,
Mar 9, 2015, 6:39:33 PM3/9/15
to django...@googlegroups.com
Thanks for the feedback Simon & Ilya.

I've done submodules in Git before, but I think I'll keep the templates in a separate repo and symbolic link to the repo ...
Reply all
Reply to author
Forward
0 new messages