Skip to content

Instantly share code, notes, and snippets.

@HugoKuo
Created February 24, 2014 05:23
Show Gist options
  • Save HugoKuo/9182379 to your computer and use it in GitHub Desktop.
Save HugoKuo/9182379 to your computer and use it in GitHub Desktop.
root@ny-workshop:/home/swiftstack# ./create-accounts.py
Create ws000
1393219098.576729 [30110] INFO base.py:188 - Raven is not configured (logging is disabled). Please see the documentation for more information.
Traceback (most recent call last):
File "./create-accounts.py", line 26, in <module>
response = client.post(reverse('signup'), formdata)
File "/usr/lib/python2.7/dist-packages/django/test/client.py", line 463, in post
response = super(Client, self).post(path, data=data, content_type=content_type, **extra)
File "/usr/lib/python2.7/dist-packages/django/test/client.py", line 297, in post
return self.request(**r)
File "/usr/lib/python2.7/dist-packages/django/test/client.py", line 424, in request
six.reraise(*exc_info)
File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 92, in get_response
response = middleware_method(request)
File "/usr/lib/python2.7/dist-packages/django/middleware/common.py", line 57, in process_request
host = request.get_host()
File "/usr/lib/python2.7/dist-packages/django/http/request.py", line 72, in get_host
"Invalid HTTP_HOST header (you may need to set ALLOWED_HOSTS): %s" % host)
django.core.exceptions.SuspiciousOperation: Invalid HTTP_HOST header (you may need to set ALLOWED_HOSTS): testserver
@HugoKuo
Copy link
Author

HugoKuo commented Feb 25, 2014

My script looks normal :

#!/usr/bin/python
import time

from django.test.client import Client
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse

client = Client()

## Fixed me : Default account ID from ws000-ws100
for x in range(60,101):
    ID = "ws"+'{:03}'.format(x)
    print "Create %s" % ID
    formdata = {
                'invite_code': '',
                'username': ID,
                'email': 'support@swiftstack.com',
                'first_name': ID,
                'last_name': ID,
                'organization_name': ID,
                'password1': 'password',
                'password2': 'password',
                'timezone': 'US/Pacific',
                }

    response = client.post(reverse('signup'), formdata)
    print response
    print " "
    time.sleep(1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment