Answer the question
In order to leave comments, you need to log in
How to solve list indices must be integers or slices, not str?
I get an error list indices must be integers or slices, not str in get_form UpdateView on this line:
self.fields['category'] = Category.objects.all().filter(user=self.request.user)
class HomeUpdateView(UpdateView):
model = Model
fields = ['title', 'category']
success_url = '/account/home'
template_name = 'main/update/update_home.html'
def get_form(self, form_class=None):
self.fields['category'].queryset = Category.objects.all().filter(user=self.request.user)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question