change DjangoApp\vstemplate to get a DIY project structure

Nov 28, 2014 at 9:51 AM
we use a different project structure at work, just like the position of settings, wsgi etc.

so i try to find a way to change the django vstemplate which installed by ptvs tool.

nothing found, so i look into the ide install dir, find how to change the template

in case someone have the same problem as me, i write the way here down:

there to dir under ide dir:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE
  1. ProjectTemplates
  2. ProjectTemplatesCache
1 used by ptvs installer, just some zipfile conatins vstemplate.

2 is what we need, but if we repair ptvs tool, 2 will be override by 1.
ProjectTemplatesCache\Python\Web\DjangoProject.zip
this is a dir, not zip file.
   DjangoApp.pyproj   
  DjangoApp.vstemplate  
    manage.py
      requirements.txt
  settings.py
     urls.py
   wsgi.py
     __init__.py
DjangoApp.pyproj
DjangoApp.vstemplate
contains the configuration ide need when create a new project.
$safeprojectname$  
means the projectname input . it appears in almost everyfile
<TemplateContent>
    <Project File="DjangoApp.pyproj" ReplaceParameters="true">
      <ProjectItem ReplaceParameters="true" TargetFileName="manage.py">manage.py</ProjectItem>
      <ProjectItem ReplaceParameters="true" TargetFileName="$safeprojectname$\__init__.py">__init__.py</ProjectItem>
      <ProjectItem ReplaceParameters="true" TargetFileName="$safeprojectname$\urls.py">urls.py</ProjectItem>
      <ProjectItem ReplaceParameters="true" OpenInEditor="true" TargetFileName="$safeprojectname$\settings.py">settings.py</ProjectItem>
      <ProjectItem ReplaceParameters="true" TargetFileName="$safeprojectname$\wsgi.py">wsgi.py</ProjectItem>
      <ProjectItem>requirements.txt</ProjectItem>
    </Project>
  </TemplateContent>
templateContent section is the most import conf, change this is a effective way to get a DIY directory hierarchy.

remember change the $safeprojectname$ in settings urls etc.
Coordinator
Nov 28, 2014 at 4:08 PM
You can also create your own template by saving a project into your Visual Studio 201x\Templates folder in your documents (plus a few subdirectories). This is the easiest way to create your own template, though it misses some functionality.

Also, if you install or repair basically any VS extension, the changes you've made in ProjectTemplatesCache will be overwritten, so this isn't the best way to do it. You could update the zip file or create a new one and then repairs won't break you.

Our of interest, how do you structure your projects? Maybe we could add a second template.