views:

103

answers:

1

I'm trying to pass keyword arguments to a Django view using a dictionary, but I keep running into a TypeError when I try to access the URL (The error is: "add_business_contact() got an unexpected keyword argument 'info_models'"). The code is:

urlpatterns = patterns('business.views',
    # ...
    url(r'^(?P<business_id>[\w\._-]+)/edit_contact$', 'add_business_contact', {
        'info_models': [Email, PhoneNumber, URL] }, name='business_contact'),
    # ...
)

and the corresponding view:

@login_required
def add_business_contact(request, business_id, *args, **kwargs):
    # ...
    info_models = kwargs.pop('info_models', None)
    # ....

If I remove the dictionary argument from the url() function, it happily reaches and runs the view (albeit incorrectly since it doesn't have that argument). Any ideas as to why it's doing this? I'm following an example from the Django Book ( http://djangobook.com/en/2.0/chapter08/ ) if that helps at all.

+1  A: 

Wooops. A bit embarassing but I copy/pasted the function while working on it and didn't rename the original. It's working now as expected...

John Debs