-1

In My django app I have a view called 'StatsView' given below:

class StatsView(LoginRequiredMixin, View):
    login_url = '/signin/'

    def get(self, request, template='app_folder/ad_accounts/pixel_stats.html', *args, **kwargs):
        #Code
        return render(request, template, context)

app/urls.py

url(
    r'^ad_accounts/(?P<ad_account_id>[^/]+)/pixel_stats',
    StatsView.as_view(),
    name="pixel_stats"
),

template pixel_stats.html

<p> test</p>

However when I go to localhost:8000/ad_accounts/acctid/pixel_stats/ I keep running into a Template DoesNotExist Error. I cant seem to figure out where Im going wrong. Ive added a bunch of URLs and havent run into this issue for any one them.

My app structure is as follows:

project/
  app/
    templates/
      app_folder/
        ad_accounts/
          pixel_stats.html
    views/
      ad_accounts/
        stats.py
Beginner
  • 2,643
  • 9
  • 33
  • 51
  • 1
    Your template path does not seem correct given your directory structure. – donkopotamus Oct 12 '16 at 01:30
  • All previous urls and templates follow the exact same structure and did not throw this error – Beginner Oct 12 '16 at 01:31
  • Try `template='app/templates/app_folder/ad_accounts/pixel_stats.html'` or `template='app_folder/ad_accounts/pixel_stats.html'`. If it doesn't help, please show a similar URL that works. – Ella Sharakanski Oct 12 '16 at 01:36
  • my bad, in the view the template is already setup as `template='app_folder/ad_accounts/pixel_stats.html'`. I just corrected in the post – Beginner Oct 12 '16 at 01:39
  • Does this help? http://stackoverflow.com/a/36312587/1332509 Also please show a URL that works. Is there any template URL that works? – Ella Sharakanski Oct 12 '16 at 01:47

1 Answers1

0

Silly mistake. Solved it by adding a $ at the end in my url.

url(
    r'^ad_accounts/(?P<ad_account_id>[^/]+)/pixel_stats/$',
    StatsView.as_view(),
    name="pixel_stats"
),
Beginner
  • 2,643
  • 9
  • 33
  • 51