0

I'm a beginner working with django. When working with Class Based Views, I constantly keep getting this error:

Reverse for 'products.views.'filter_by_led' with arguments '()' 

and

keyword arguments '{}' not found. 

Sorry if I don't bring more context to the table, the point is, I don't understand what keyword arguments are, and I know that's the reason why I don't know how to solve this.

hivert
  • 10,579
  • 3
  • 31
  • 56
Camilo Sanchez
  • 1,262
  • 2
  • 13
  • 17
  • 4
    Unless you have any url patterns that use keyword arguments, you basically don't need to care about the error message. All you need to know is that Django could not find a URL pattern to match. – Martijn Pieters Mar 06 '14 at 13:55
  • Here's a good explanation of positional args, and keyword args: http://stackoverflow.com/questions/36901/what-does-double-star-and-star-do-for-python-parameters – Chris Matta Mar 06 '14 at 13:59

2 Answers2

1

Keyword argument are argument which are passed using their name. For example in the call

foo(1, 3, length=4)

argument 1 and 3 are usual argument whereas length is a keyword argument. You should read a tutorial such as this one or this official tutorial

hivert
  • 10,579
  • 3
  • 31
  • 56
0

keyword arguments (kwargs) are those represented as a dictionary

{'parameter_name1': value1, 'parameter_name2': value2, ...}

Once you get them in a function func, you can access to them as kwargs['parameter_name1']

def func(*args, **kwargs): ----> args: positional arguments, kwargs: keyword arguments

juankysmith
  • 11,839
  • 5
  • 37
  • 62