Unexpected keyword argument when calling a function

0 views
Skip to first unread message

Greg

unread,
Jul 7, 2007, 7:07:46 PM7/7/07
to Django users
Hello,
I have the following line in my urls.py file

r'^(?P<manufacturer_id>\d+)/(?P<collection_id>\d+)/styles/$',
'mysite.rugs.views.showcollection'),

//////////////////////

I have the following function defined in my views.py file

def showcollection(request, manufacturer_id, collection_id):
s = Style.objects.filter(collection=collection_id)
return render_to_response('thecollectionpage.html', {'coll': s})

//////////////////////

When I go to that url I get the following error:

TypeError at /rugs/2/1/styles/
showcollection() got an unexpected keyword argument 'collection_id'
Request Method: GET
Request URL: http://127.0.0.1:8000/rugs/2/1/styles/
Exception Type: TypeError
Exception Value: showcollection() got an unexpected keyword argument
'collection_id'
Exception Location: c:\Python24\lib\site-packages\django\core\handlers
\base.py in get_response, line 77

////////////////////////////

I done this before with just one variable and it's always been (?
P<object_id>\d+). Can I change the name from object_id to
manufacturer_id and collection_id? And can I send two variables
(three including request)?

Thanks

Todd O'Bryan

unread,
Jul 7, 2007, 8:01:01 PM7/7/07
to django...@googlegroups.com
According to the code I have, this should be working. Try changing it
to

def showcollection(request, manufacturer_id=None, collection_id=None):

and see if that makes any difference.

Karen Tracey

unread,
Jul 7, 2007, 8:05:03 PM7/7/07
to django...@googlegroups.com
On 7/7/07, Greg <gms...@hotmail.com> wrote:
I done this before with just one variable and it's always been (?
P<object_id>\d+).  Can I change the name from object_id to
manufacturer_id and collection_id?  And can I send two variables
(three including request)?

Yes, you can change the names and you can have more than one variable in addition to request passed into your view function.  I can't immediately see anything wrong with your code (it looks very similar to some of my own, which does much the same thing and works fine).  It almost seems as though an old showcollection() definition is being found somewhere, one that doesn't have the collection_id argument.  Any way that could be happening?

Karen

Greg

unread,
Jul 7, 2007, 9:58:25 PM7/7/07
to Django users
Karen,
Thanks...that is exactly what happened. I copied the old function but
forgot to delete it

Thanks

On Jul 7, 7:05 pm, "Karen Tracey" <kmtra...@gmail.com> wrote:

Reply all
Reply to author
Forward
0 new messages