title: Template does not exist. Django looking for wrong path
body: <p>im following a django tutorial but have had this error coming up for a while now. i've had the course code up next to mine to comepare it to try to find the bug but i haven't had any luck with it</p>
  
  <pre><code>TemplateDoesNotExist at /posts/new/
  posts/post_form.html
  Request Method: GET
  Request URL:    http://127.0.0.1:8000/posts/new/
  Django Version: 1.11
  Exception Type: TemplateDoesNotExist
  Exception Value:    
  posts/post_form.html
  Exception Location: /Users/chrismaltez/anaconda3/envs/simplesocialenv/lib/python3.5/site-packages/django/template/loader.py in select_template, line 53
  Python Executable:  /Users/chrismaltez/anaconda3/envs/simplesocialenv/bin/python
  Python Version: 3.5.0
  Python Path:    
  ['/Users/chrismaltez/Desktop/pycharmprojects/UDEMY/simple_social_clone/simplesocial',
   '/Users/chrismaltez/anaconda3/envs/simplesocialenv/lib/python35.zip',
   '/Users/chrismaltez/anaconda3/envs/simplesocialenv/lib/python3.5',
   '/Users/chrismaltez/anaconda3/envs/simplesocialenv/lib/python3.5/plat-darwin',
   '/Users/chrismaltez/anaconda3/envs/simplesocialenv/lib/python3.5/lib-dynload',
   '/Users/chrismaltez/anaconda3/envs/simplesocialenv/lib/python3.5/site-packages']
  
  Here is the postmortem traceback:
  
  Template-loader postmortem
  Django tried loading these templates, in this order:
  
  Using engine django:
  
  django.template.loaders.filesystem.Loader: /Users/chrismaltez/Desktop/pycharmprojects/UDEMY/simple_social_clone/simplesocial/templates/posts/post_form.html (Source does not exist)
  django.template.loaders.app_directories.Loader: /Users/chrismaltez/anaconda3/envs/simplesocialenv/lib/python3.5/site-packages/django/contrib/admin/templates/posts/post_form.html (Source does not exist)
  django.template.loaders.app_directories.Loader: /Users/chrismaltez/anaconda3/envs/simplesocialenv/lib/python3.5/site-packages/django/contrib/auth/templates/posts/post_form.html (Source does not exist)
  django.template.loaders.app_directories.Loader: /Users/chrismaltez/anaconda3/envs/simplesocialenv/lib/python3.5/site-packages/bootstrap3/templates/posts/post_form.html (Source does not exist)
  django.template.loaders.app_directories.Loader: /Users/chrismaltez/Desktop/pycharmprojects/UDEMY/simple_social_clone/simplesocial/accounts/templates/posts/post_form.html (Source does not exist)
  django.template.loaders.app_directories.Loader: /Users/chrismaltez/Desktop/pycharmprojects/UDEMY/simple_social_clone/simplesocial/groups/templates/posts/post_form.html (Source does not exist)
  django.template.loaders.app_directories.Loader: /Users/chrismaltez/Desktop/pycharmprojects/UDEMY/simple_social_clone/simplesocial/posts/templates/posts/post_form.html (Source does not exist)
  
  This is the last line of the traceback:
  
  raise TemplateDoesNotExist(', '.join(template_name_list), chain=chain) 
  </code></pre>
  
  <p>From what I can tell, it might not be looking in the right place</p>
  
  <pre><code>-simple_social_clone
  --simplesocial
  ---posts
  ----templates
  -----posts
  ------post_form.html
  
  from django.conf.urls import url, include
  from django.contrib import admin
  from django.conf import settings
  from . import views
  
  urlpatterns = [
      url(r'^admin/', admin.site.urls),
      url(r'^$', views.HomePage.as_view(), name='home'),
      url(r'^accounts/', include('accounts.urls', namespace='accounts')),
      url(r'^accounts/', include('django.contrib.auth.urls')),
      url(r'^test/$', views.TestPage.as_view(),name='test'),
      url(r'^thanks/$', views.ThanksPage.as_view(),name='thanks'),
      url(r'^posts/', include('posts.urls',namespace='posts')),
      url(r'^groups/', include('groups.urls',namespace='groups')),
  ]
  
  if settings.DEBUG:
      import debug_toolbar
      urlpatterns = [
          url(r'^__debug__/', include(debug_toolbar.urls))
      ] + urlpatterns
  </code></pre>
  
  <p>here is project level views.py</p>
  
  <pre><code>from django.views.generic import TemplateView
  
  class TestPage(TemplateView):
      template_name = 'test.html'
  
  class ThanksPage(TemplateView):
      template_name = 'thanks.html'
  
  
  class HomePage(TemplateView):
      template_name = 'index.html'
  </code></pre>
  
  <p>Here is app level views.py</p>
  
  <pre><code>from django.shortcuts import render
  from django.contrib import messages
  from django.contrib.auth.mixins import LoginRequiredMixin
  from django.core.urlresolvers import reverse_lazy
  
  from django.http import Http404
  from django.views import generic
  
  from braces.views import SelectRelatedMixin
  # Create your views here.
  
  from . import models
  from . import forms
  
  from django.contrib.auth import get_user_model
  User = get_user_model()
  
  class PostList(SelectRelatedMixin,generic.ListView):
      model = models.Post
      select_related = ('user','group')
  
  class UserPosts(generic.ListView):
      model = models.Post
      template_name = 'posts/user_post_list.html'
  
      def get_queryset(self):
          try:
              self.post.user = User.objects.prefetch_related('posts').get(
                  username__iexact=self.kwargs.get('username')
              )
          except User.DoesNotExist:
              raise Http404
          else:
              return self.post_user.posts.all()
  
      def get_context_data(self, **kwargs):
          context = super().get_context_data(**kwargs)
          context['post_user'] = self.post_user
          return context
  
  class PostDetail(SelectRelatedMixin, generic.DetailView):
      model = models.Post
      select_related = ('user','group')
  
      def get_queryset(self):
          queryset = super().get_queryset()
          return queryset.filter(user__username__iexact=self.kwargs.get('username'))
  
  class CreatePost(LoginRequiredMixin, SelectRelatedMixin, generic.CreateView):
  
      fields = ('message','group')
      model = models.Post
  
      def form_valid(self, form):
          self.object = form.save(commit=False)
          self.object.user = self.request.user
          self.object.save()
          return super().form_valid(form)
  
  class DeletePost(LoginRequiredMixin, SelectRelatedMixin, generic.DeleteView):
      model = models.Post
      select_related = ('user','group')
      success_url = reverse_lazy('posts:all')
  
      def get_queryset(self):
          queryset = super().get_queryet()
          return queryset.filter(user_id = self.request.user.id)
  
      def delete(self, *args, **kwargs):
          messages.success(self.request,'Post Deleted')
          return super().delete(*args,**kwargs)
  </code></pre>
  
  <p>Here is app level urls.py:</p>
  
  <pre><code>from django.conf.urls import url
  
  from . import views
  
  app_name = 'posts'
  
  urlpatterns = [
  
      url(r'^$', views.PostList.as_view(), name='all'),
      # url(r'new/$', views.CreatePost.as_view(),name='create'),
      url(r"new/$", views.CreatePost.as_view(), name="create"),
      url(r'by/(?P&lt;username&gt;[-\w]+)/$', views.UserPosts.as_view(),name='for_user'),
      url(r'by/(?P&lt;username&gt;[-\w]+)/(?P&lt;pk&gt;\d+)/$', views.PostDetail.as_view(),name='single'),
      url(r'delete/(?P&lt;pk&gt;\d+)/$', views.DeletePost.as_view(), name='delete'),
  ]
  </code></pre>
  
  <p>Here is the models at app level: </p>
  
  <pre><code>from django.db import models
  from django.core.urlresolvers import reverse
  from django.conf import settings
  
  import misaka
  # Create your models here.
  
  from groups.models import Group
  from django.contrib.auth import get_user_model
  User = get_user_model()
  
  from django import template
  register = template.Library()
  
  class Post(models.Model):
      user = models.ForeignKey(User, related_name='posts')
      created_at = models.DateTimeField(auto_now=True)
      #auto generates datetime stamp of post
      message = models.TextField()
      message_html = models.TextField(editable=False)
      #doesnt allow others to edit post
      group = models.ForeignKey(Group, related_name='posts', null=True, blank=True)
  
      def __str__(self):
          return self.message
  
      def save(self, *args, **kwargs):
          self.message_html = misaka.html(self.message)
          super().save(*args,**kwargs)
  
      def get_absolute_url(self):
          return reverse(
              'posts:single',
              kwargs={
                  'username':self.user.username,
                  'pk':self.pk
              }
          )
  
      class Meta:
          ordering = ['-created_at']
          unique_together = ['user','message']
  </code></pre>
  
  <p>here is post_form.html</p>
  
  <pre><code>{% extends 'posts/post_base.html' %}
  {% load bootstrap3 %}
  
  {% block post_content %}
  &lt;h4&gt;Create a new Post&lt;/h4&gt;
  &lt;form id="postForm" action="{% url 'posts:create' %}" method="POST"&gt;
      {% csrf_token %}
      {% bootstrap_form form %}
      &lt;input type="submit" value="Post" class="btn btn-primary btn-large"&gt;
  
  
      &lt;/form&gt;
  
  
  {% endblock %}
  </code></pre>
  
  <p>finally here is the project templates level:</p>
  
  <pre><code>enter code here     &lt;/div&gt;
  
      &lt;/nav&gt;
      &lt;div class="container mycontent"&gt;
  
          {% block content %}
  
          {% endblock %}
  
  
          &lt;/div&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>[<img src="https://i.stack.imgur.com/yiCR5.png" alt="enter image description here">][2]</p>