title: Best practices for layout out Angular/Django apps
body: <p>I'm fairly new to both Django and Angular. I recognize this is subjective and there are likely many ways to do it, but I'm wondering what best practices people can recommend for laying out such an application. I'm specifically thinking of the case of rich, SPA with the backend being mostly or entirely a RESTful API server, but then I'd like to have a common approach for any apps that serve significant views from Django. (I haven't done enough to decide if the latter warrants using Angular or may be more trouble than its worth).</p>
  
  <p>Specifically:</p>
  
  <p>What are pros/cons of maintaining the front-end code in a separate directory/repository from the backend versus, say, inside a "static" subdirectory of the Django app? In my case I'm the sole developer for now, which has some impact on this decision, but I can still consider myself separate "teams" of back-end, front-end, designer, etc. in the sense that my workflow will put me in one of these roles at a time.</p>
  
  <p>My setup is basically a development machine, SCM in GitHub, and hosted publicly on WebFaction (shared web hosting). I will down the line want to easily grab projects on different development machines, but the primary workflow is just one dev, one prod installation. That said, I'm interested in best practices in real-world projects as I hope a future job may be working with Django.</p>
  
  <p><strong>ADDED</strong>: Another point I'm very unsure about is whether the Angular app should/must be bootstrapped by Django. That is, should the front page be served by Django and injected with any data? </p>
  
  <p>PROS:</p>
  
  <ul>
  <li>Can configure URL paths and even API endpoints that change from dev to production, without any alternate config and without these being hard-coded in front-end.</li>
  <li>This is maybe necessary for authentication? Unclear to me having not done this yet...</li>
  <li>Allows use of tools like the Django debug toolbar app. </li>
  </ul>
  
  <p>CONS: </p>
  
  <ul>
  <li>Couples the front-end to the back-end. What If I want to swap out the latter? What if I want the front-end to work in a sandbox with mock data? </li>
  <li>Seems to strongly favor moving <em>all</em> Angular stuff into the Django app layout. At the same time, I don't like having a mix of Angular partials in one place and Django template(s) in another. I am already resolved not to mix NG and DJ templates, as I don't believe much good will come of this. </li>
  </ul>