Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6018399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:16:12+00:00 2026-05-23T03:16:12+00:00

I’m following a Django tutorial and suddenly when I try to access http://127.0.0.1:8000/admin/ it

  • 0

I’m following a Django tutorial and suddenly when I try to access http://127.0.0.1:8000/admin/ it gives me a TemplateSyntaxError.

TemplateSyntaxError at /admin/

Caught ViewDoesNotExist while rendering: Tried results in module polls.views. Error was: ‘module’ object has no attribute ‘results’

It highlights this line:
{% url ‘django-admindocs-docroot’ as docsroot %}

The admin page worked like a charm until I got to part 3 of the tutorial and messed with the urls, although I did it exactly like they said so I doubt it’s the problem.

urls.py:

from django.conf.urls.defaults import *

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    (r'^polls/$', 'polls.views.index'),
    (r'^polls/(?P<poll_id>\d+)/$', 'polls.views.detail'),
    (r'^polls/(?P<poll_id>\d+)/results/$', 'polls.views.results'),
    (r'^polls/(?P<poll_id>\d+)/vote/$', 'polls.views.vote'),
    (r'^admin/', include(admin.site.urls)),
)

admin.py:

from polls.models import Poll
from polls.models import Choice
from django.contrib import admin

class ChoiceInline(admin.TabularInline):
    model = Choice
    extra = 0

class PollAdmin(admin.ModelAdmin):
    fieldsets = [
        (None, {'fields': ['question']}),
        ('Date information', {'fields': ['pub_date'], 'classes': ['collapse']}),
    ]
    inlines = [ChoiceInline]
    list_display = ('question', 'pub_date')
    list_filter = ['pub_date']
    search_fields = ['question']
    date_hierarchy = 'pub_date'

admin.site.register(Poll, PollAdmin)

views.py:

from django.http import HttpResponse
from polls.models import Poll
from django.template import Context, loader

def index(request):
    latest_poll_list = Poll.objects.all().order_by('-pub_date')[:5]
    t = loader.get_template('polls/index.html')
    c = Context({
        'latest_poll_list': latest_poll_list,
    })
    return HttpResponse(t.render(c))

def detail(request, poll_id):
    return HttpResponse("You're looking at poll %s. " % poll_id)

def vote(request, poll_id):
    return HttpResponse("You're voting on poll %s." % poll_id)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T03:16:12+00:00Added an answer on May 23, 2026 at 3:16 am
    Caught ViewDoesNotExist while rendering: Tried results in module polls.views. 
    Error was: 'module' object has no attribute 'results'
    

    That’s pretty much all you need. Ignore the TemplateSyntaxError, it’s not related to the template at all. Django is telling you that you don’t have this:

    def results(request):
        # do something
    

    In your views.py. You’ll get ViewDoesNotExist errors outside the admin when you start writing urls and referencing functions that don’t actually exist in them, so make sure as you progress that you either ensure you have such stub functions that just return a basic 200, or you comment out those urls until you need them.

    Technically speaking this is an extension of a python error. If you ran:

    $ python manage.py shell
    >>> from poll import views
    x = views.results
    

    You’d get an AttributeError.

    Since you asked why, if you look in Django/core/urlresolvers.py you’ll see the line:

    _callable_cache = {} # Maps view and url pattern names to their view functions.
    

    So basically a cache of view mappings (urls or whatever) to functions is made in the form of a hashmap (dictionary). This is constructed by this function:

    def _get_callback(self):
        if self._callback is not None:
            return self._callback
        try:
            self._callback = get_callable(self._callback_str)
        except ImportError, e:
            mod_name, _ = get_mod_func(self._callback_str)
            raise ViewDoesNotExist("Could not import %s. Error was: %s" % (
                                                                mod_name, str(e)))
        except AttributeError, e:
            mod_name, func_name = get_mod_func(self._callback_str)
            raise ViewDoesNotExist("Tried %s in module %s. Error was: %s" % (
                                                       func_name, mod_name, str(e)))
        return self._callback
    callback = property(_get_callback)
    

    Which evaluates each callback to check it exists (newlines are mine).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.