Skip to content Skip to sidebar Skip to footer

'__proxy__' Object Has No Attribute 'get' In Createview

So I'm thinking that this is not the right way to do things, but I am trying to learn django and I am trying some things out. I am trying to set a foreign key for my Formula model,

Solution 1:

The reason for your error is that form_valid should return a Response object, and you are returning a URL.

Rather than do this manually you should just call the parent method which will redirect to the success_url that you have already defined:

defform_valid(self, form):
    self.object = form.save(commit = False)
    self.object.maker = Cooker.objects.get(pk=1)
    form.save()
    returnsuper(FormulaCreate, self).form_valid(form)

Post a Comment for "'__proxy__' Object Has No Attribute 'get' In Createview"