We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
My code:
def new_list(request): """ item.objects.create 是创建Item对象的简化方式无需再掉用.save()方法 """ form = ItemForm(data=request.POST) if form.is_valid(): list_ = List() print(request) list_.owner = request.user list_.save() form.save(for_list=list_) return redirect(list_) else: return render(request, 'home.html', {"form": form})
@patch('lists.models.List') @patch('lists.forms.ItemForm') def test_list_owner_is_saved_if_user_is_authenticated(self, mockItemFormClass, mockListClass): user = User.objects.create(email='[email protected]') self.client.force_login(user) #print(settings.AUTHENTICATION_BACKENDS[0]) self.client.post('/lists/new', data={'text': 'new item'}) mock_list = mockListClass.return_value self.assertEqual(mock_list.owner, user)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
My code:
The text was updated successfully, but these errors were encountered: