Skip to content
Advertisement

Django got an unexpected keyword argument

I’m trying to create an archive so I pass to the view the arguments year and month.

However, I get an error with the code below and I can’t figure out what it means and how to solve it:

JavaScript

What can be wrong?

views.py

JavaScript

urls.py

JavaScript

Update:

models.py

JavaScript

Template

JavaScript

Update 2: error

JavaScript

Advertisement

Answer

There is something wrong with your parameters names :

JavaScript

Replace year and month by year_id and month_id and it should work.

EDIT:

For your second error, and accordingly to this question, your archive() view does not return a proper response.

Here is your code, fixed :

JavaScript

Edit 2 :

Your template can’t iterate through months because the var does not exist in context:

JavaScript

Do you see the difference ? You use caps for your variables names (“Months”) in the first one, while the template rendered, which is case-sensitive, looks for a lower case variable (“months”).

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement