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 254709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:52:10+00:00 2026-05-11T21:52:10+00:00

So I am just starting out on learning Django, and I’m attempting to complete

  • 0

So I am just starting out on learning Django, and I’m attempting to complete one of the sample applications from the book. I’m getting stuck now on creating DRY URL’s. More specifically, I cannot get my context processor to work. I create my context processor as so:

from django.conf import settings
#from mysite.settings import ROOT_URL

def root_url_processor(request):
  return {'ROOT_URL': settings.ROOT_URL}

and I placed this file in my app, specifically, mysite/photogallery/context_processors.py . My settings.py file in the root of my project contains:

TEMPLATE_CONTEXT_PROCESSORS = ('mysite.context_processors',)

When I try to go to the ROOT_URL that I’ve also specified in my settings.py, I receive this error:

TypeError at /gallery/

‘module’ object is not callable

/gallery/ is the ROOT_URL of this particular application. I realize that perhpas this could mean a naming conflict, but I cannot find one. Furthermore, when I comment out the TEMPLATE_CONTEXT_PROCESSORS definition from settings.py, the application actually does load, however my thumbnail images do not appear (probably because my templates do not know about ROOT_URL, right?). Anyone have any ideas as to what the problem could be?

EDIT: Here’s some information about my settings.py in case it is of use:

ROOT_URLCONF = 'mysite.urls'

ROOT_URL = '/gallery/'
LOGIN_URL = ROOT_URL + 'login/'
MEDIA_URL = ROOT_URL + 'media/'
ADMIN_MEDIA_PREFIX = MEDIA_URL + 'admin/'

TEMPLATE_DIRS = (
    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
)

TEMPLATE_CONTEXT_PROCESSORS = ('mysite.photogallery.context_processors',)

EDIT2: I’m going to add some information about my url files. Essentially I have a root urls.py, a real_urls.py which is also located at the root, and a urls.py that exists in the application. Basically, root/urls.py hides ROOT_URL from real_urls.py, which then includes my app’s urls.py.

root/urls.py:

from django.conf.urls.defaults import *
#from mysite.settings import ROOT_URL
from django.conf import settings

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    # Example:
    (r'^blog/', include('mysite.blog.urls')),
                       url(r'^%s' % settings.ROOT_URL[1:], include('mysite.real_urls')),
    )

root/real_urls.py:

from django.conf.urls.defaults import *
from django.contrib import admin

urlpatterns = patterns('', url(r'^admin/(.*)', admin.site.root),
                       url(r'^', include('mysite.photogallery.urls')),
                       )

root/photogallery/urls.py (note that this one probably is not causing any of the problems, but I’m adding it here in case anyone wants to see it.):

from django.conf.urls.defaults import *
from mysite.photogallery.models import Item, Photo

urlpatterns = patterns('django.views.generic', url(r'^$', 'simple.direct_to_template', kwargs={'template': 'index.html', 'extra_context': {'item_list': lambda: Item.objects.all()}
                                                                                               },
                                                   name='index'), url(r'^items/$', 'list_detail.object_list', kwargs={'queryset': Item.objects.all(), 'template_name': 'items_list.html', 'allow_empty': True },
                                                                      name='item_list'), url(r'^items/(?P<object_id>\d+)/$', 'list_detail.object_detail', kwargs={'queryset': Item.objects.all(), 'template_name': 'items_detail.html' }, name='item_detail' ), url(r'^photos/(?P<object_id>\d+)/$', 'list_detail.object_detail', kwargs={'queryset': Photo.objects.all(), 'template_name': 'photos_detail.html' }, name='photo_detail'),)
  • 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-11T21:52:10+00:00Added an answer on May 11, 2026 at 9:52 pm

    TEMPLATE_CONTEXT_PROCESSORS should contain a list of callable objects, not modules. List the actual functions that will transform the template contexts. Link to docs.

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

Sidebar

Related Questions

I am just starting out learning to build interfaces, but the book I am
I'm just starting out learning C# and I've become stuck at something very basic.
I'm just starting out learning ASP.NET. From what I understand, ASP.NET differs from old
Just starting out on C# and I keep getting stuck on this particular piece
I'm just starting out learning OpenCL. I'm trying to get a feel for what
I'm just starting out in learning Ruby and I've written a program that generates
Just starting out, this should be a simple one but I haven't been able
I'm just starting out learning javascript, and tried to write a little script that
I'm just starting out learning python with GEdit plus various plugins as my IDE.
I am just starting out learning Clojure and Emacs. I have got Clojure Box

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.