Django 400 Bad Request, even with Allowed Hosts

I just had to break down django itself to understand why I could not get rid of my error.

It turns out underscores in domain names is invalid according to the RFCs.

Make sure your domains do not have underscores. If they do, you’ll have to patch django’s host validation function:

host_validation_re = re.compile(r"^([a-z0-9.-]+|\[[a-f0-9]*:[a-f0-9:]+\])(:\d+)?$")

Advertisements

One thought on “Django 400 Bad Request, even with Allowed Hosts

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s