views:

82

answers:

2
this_category = Category.objects.get(name=cat_name)

gives error: get() takes exactly 2 non-keyword arguments (1 given)

I am using the appengine helper, so maybe that is causing problems. Category is my model. Category.objects.all() works fine. Filter is also similarily not working.

Thanks,

+1  A: 

Do you have any functions named name or cat_name? If so, try changing them or the variable names you are using and trying again.

betamax
no, no functions named name or cate_name if I change it to id=1 inside the parentheses it still doesn't work
pimcoooooooo
A: 

The helper maps the Django model manager (Category.objects in this case) back to the class instance of the model via the appengine_django.models.ModelManager. Through the inheritance chain you eventually come to appengine.ext.db.Model.get(cls, keys, **kwargs) so that is why you are seeing this error. The helper does not support the same interface for get that Django does. If you do not want to get by primary key, you must use a filter

To do your query, you need to use the GAE filter function like this:

this_category = Category.objects.all().filter('name =', cat_name).get()
dar