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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:16:02+00:00 2026-05-24T23:16:02+00:00

I am working on a django project and when I try to run this

  • 0

I am working on a django project and when I try to run this function it returns that there can only be one argument given, but there is only one argument given.

from django.http import HttpResponse, Http404
from django.template import Context
from django.template.loader import get_template
from django.contrib.auth.models import User

def main_page(request):
    template = get_template('main_page.html')
    variables = Context({
            'head_title':u'Bookmarks!',
            'page_title':u'Welcome to bookmarks!',
            'page_body': u'store and share the bookmarks',
            })
    output = template.render(variables)
    return HttpResponse(output)

Url pattern

from django.conf.urls.defaults import patterns, include, url
from socialnetwork.bookmarks.views import *
urlpatterns = patterns('',
    (r'^user/(\w+)/$', main_page),

)

Traceback:

Environment:


Request Method: GET
Request URL: http://127.0.0.1:8000/user/Colin/

Django Version: 1.3
Python Version: 2.7.1
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'socialnetwork.bookmarks']
Installed Middleware:
 ('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.7/dist-packages/django/core/handlers/base.py" in   get_response
  111.                             response = callback(request, *callback_args,     **callback_kwargs)

Exception Type: TypeError at /user/Colin/
Exception Value: main_page() takes exactly 1 argument (2 given)
  • 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-24T23:16:02+00:00Added an answer on May 24, 2026 at 11:16 pm

    I suspect that your URL pattern captures some other variable. If you attach a URL pattern to a view and that URL pattern captures any values, you need to have that view set up to take an argument for each captured value on top of the request argument, which is always first. So, let’s say you’ve got a pattern

    (r'^mainpage(\d+)/$', myview)
    

    myview() needs to be defined like so:

    def myview(request, digit):
        # do something
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a django project that I am working on. The project is
I'm working on a Django project that will need jQuery, jQuery UI , and
I've been working on a django project for a while now that uses grappelli
I have been trying to get xapian working django haystack for a project im
I'm currently working on a project in Django and currently I'm working on a
I was working on my project for a while and recently noticed that when
I am working on a Django project in which users should be allowed to
So I'm working on migrating a Django project to virtualenv/pip. I'd like to use
I am working with my friends on a Django project. The project has dependencies

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.