Question: I'm making a weblog site in Django. I have a Blog model like this:

```
class Blog(models.Model):
    name = models.CharField(max_length=255)
    slug = models.SlugField(max_length=255)
    ...

```

And I want the front pages of each blog to be at URLs like this: www.example.com/blog-slug/

However, I'm also using Flatpages and will want that to be able to match URLs like this: www.example.com/flat-page/

So urlpatterns like this won't work:

```
urlpatterns = patterns('',
    (r'^(?P<blog_slug>[-\w]+)/$', 'weblog_index', {}),
    ...
    (r'^', include('django.contrib.flatpages.urls')),
)

```

because all Flatpages URLs will get trapped by the first pattern. I guess I want the first pattern to *only* match valid slugs from the Blog model, but I'm not sure how to do that.

Answer: 
The urllib2 ProxyHandler is not designed to support the SOCKS protocol. Perhaps [this answer](https://stackoverflow.com/questions/2537726/using-urllib2-with-socks-proxy) would help.
UPDATE: I am located behind the great firewall of china. This was compounding the problem. The gfw was both breaking connections and doing DNS poisoning.

I have not managed to get any of the urllib2 solutions working. But pycurl does seem to work and it gets around the "connection reset" problem. fb/twitter were still blocked though.

Adding their IPS to my hosts file works - so for a larger scale solution, setting up a dns proxy is necessary.