302 looks Okay as you're being redirect to LOGIN_REDIRECT_URL. During posting new branch, start your URL with `/` like r = self.client.post('/brand/new/', {'name': 'poko'})
On Thu, 4 Feb 2016 at 22:32 JAMES DAMILD ETIENNE <damil...@gmail.com> wrote: > Hi , will some help with this please , > I am writting a django unittest for a web app. when i do a post like > that : > > > > r = self.client.post(reverse('login'), {'username': 't...@hotmail.com', > 'password': '12345'}) > print 'logins page load>>', r.status_code > > the status code returns 302. it's that normal ? > > after i try to add some data to the create view like this : > > > def test_brand_create(self): > r = self.client.get(reverse('brand_new'), follow=True) > self.assertEqual(r.status_code, 200, msg="brand_new Page loads") > print 'brand_new loads >>>',r.status_code > > r = self.client.post(brand/new/', {'name': 'poko'}) > print 'brand new post>>>' ,r.status_code > > > brand = Brand.objects.get(name='poko') ( this doesn't return anything > error:>>> (DoesNotExist: Brand matching query does not exist.) it seems that > the values didn't get posted via the url ) > > self.assertIsNotNone(brand, msg="brand object created") > print "brand object created>>>",brand > > > any idea what am doing wrong ? > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-users+unsubscr...@googlegroups.com. > To post to this group, send email to django-users@googlegroups.com. > Visit this group at https://groups.google.com/group/django-users. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/90d21384-c1f4-4622-be1e-738682cc529e%40googlegroups.com > <https://groups.google.com/d/msgid/django-users/90d21384-c1f4-4622-be1e-738682cc529e%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAByqUggg6%3DggX2e8owedwba_XPN8K7YBjQ%3DB-uF5VAKfeB7Z5g%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.