Saturday, September 30, 2017

Re: Bug to set session in Django Test?

There's a test in Django's test suite for this:

I guess you'll need to figure out how your project differs from that.

On Saturday, September 30, 2017 at 6:30:25 AM UTC-4, ThePhi wrote:

I have troubles setting cookie in Django test.

class Test_views(TestCase):        def test_set_cookie(self):          session = self.client.session          session['mycookie'] = 'testcookie'          response = self.c.get(reverse('homepage'))           ...

I print the cookies in the Views to be sure:

...   def homepage(request):          print(request.session.keys())          ...

And indeed, the cookie mycookie doesn't exist.

Is it a bug?

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
To post to this group, send email to
Visit this group at
To view this discussion on the web visit
For more options, visit

No comments:

Post a Comment