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

  • SEARCH
  • Home
  • 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 8024451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:52:31+00:00 2026-06-04T22:52:31+00:00

I am attempting to build a REST-type JSON API for my app, and while

  • 0

I am attempting to build a REST-type JSON API for my app, and while I’m testing it, I keep getting a cryptic error when I hit the URL of my page.

URLconf:

url(r'^calendar/(?P<id>\d+)/(?P<year>\d+)/(?P<month>\d+)/$', 'calendar_resource'),

views.py:

def json_view(func):
    def wrapper(*args, **kwargs):
        result = func(*args, **kwargs)
        return HttpResponse(json.dumps(result), mimetype="text/json")
    return wrapper    

@json_view
def calendar_resource(request, id, month, year):
    if id != request.user.id:
        return HttpResponseForbidden()
    thisMonthEnd = datetime.datetime(year, month, calendar.mdays[month])
    thisMonthStart = datetime.datetime(year, month, 1)
    l = Lesson.objects.filter(student__teacher = request.user).filter(startDate__lte=thisMonthEnd).filter(endDate__gte=thisMonthSta‌​rt)
    lessonList = list(l)
    return lessonList

I’m converting the QuerySet result to a list so I can do more operations on it (i.e. insert records that wouldn’t be returned in the query) before passing the list back as JSON for processing by fullCalendar.

ETA: This is the original question that led me to use this implementation.

Traceback:

Environment:
Request Method: GET
Request URL: http://localhost:5678/calendar/1/2012/5/

Django Version: 1.3.1
Python Version: 2.6.5
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.humanize',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.admin',
 'lessons',
 'registration']
Installed Middleware:
('django.middleware.csrf.CsrfViewMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)

Exception Type: TypeError at /calendar/1/2012/5/
Exception Value: 'str' object is not callable
  • 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-06-04T22:52:32+00:00Added an answer on June 4, 2026 at 10:52 pm

    In your URLConf, it should be 'views.calender_resource' instead of just 'calender_resource'.

    Essentially,

    urlpatterns = patterns('',
    
        url(r'^calendar/(?P<id>\d+)/(?P<year>\d+)/(?P<month>\d+)/$', 'APP_NAME.views.calendar_resource'),
    )
    

    Or:

    urlpatterns = patterns('APP_NAME.views',
    
        url(r'^calendar/(?P<id>\d+)/(?P<year>\d+)/(?P<month>\d+)/$', 'calendar_resource'),
    )
    

    where APP_NAME is the name of the app this view belongs to.


    For reference:

    url(regex, view, kwargs=None, name=None, prefix='')
    

    You can use the url() function, instead of a tuple, as an argument to patterns(). This is convenient if you want to specify a name without the optional extra arguments dictionary. For example:

    urlpatterns = patterns('',
        url(r'^index/$', index_view, name="main-view"),
        ...
    )
    

    This function takes five arguments, most of which are optional:

    url(regex, view, kwargs=None, name=None, prefix='')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to build Firefox on my Windows Vista Ultimate machine. I keep getting
Attempting to build an interface and generics based graph and getting an odd error
I am attempting to build google-breakpad and I am getting the error File C:\google-breakpad\src\tools\gyp\pylib\gyp\generator\msvs.py,
I'm attempting to build a project called DropThings but I am getting all these
While attempting to build a website, i have gone through many online tutorials. Thanks
I am attempting to build an ASP.NET MVC 4 web app, which is similar
I am attempting to build an authentication mechanism using API keys for access. As
I'm attempting to build a gem for interacting w/ the Yahoo Placemaker API but
I'm attempting to build my first universal iOS app using the default Xcode templates
I'm attempting to build a REST based web service that provides a currency conversion

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.