Tag Archives: broken

Django 1.7, PyCharm, and Apache

I’ve had some ongoing problems with PyCharm support for Django since the 1.7 release. Here is a summary.

WSGI Broke

The entire app failed to run under Apache. This caused some moments of terror. The WSGI file needed to be edited.

This code started on version 1.3. The old WSGI configuration worked until 1.7. This discussion thread described the behaviour, which bites projects started pre-1.4. See also Issue #23437 describes the WSGI problem, and the official release notes under app-loading changes.

The correct call to initialize WSGI is:

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()


PyCharm Testing Broke

Tests in PyCharm broke. This a case of being bitten by older code again. Django uses the standard Python unittest module now. I had to go through dozens of files and tweak the import statements.

Update: LH asked for more information.

In my unit testing, I used the old-style Django test classes and had import statements like:

from django.test import TestCase

which must be changed to:

from unittest import TestCase

in order to use the built-in Python unit testing core.

PyCharm Django Console Broke

This is kind of annoying. The problem isn’t so much PyCharm itself but Django “fixed” a long-standing “bug”. Now what used to work fine doesn’t. Per the app-loading changes in the 1.7 release notes, one must, every time they start the Django console from within PyCharm, execute the following commands:

import django

This became annoying enough I hacked the Django helper


and added the two lines to that file. Problem resolved.


Fixing Windows 7 Network on VMware

After installing Windows 7 in a VMware virtual machine, it could not activate the networking card. The Device Manager claimed that it could not recognize the NIC, despite VMware Tools being installed.

To fix the problem, I shut down the virtual machine and added the following to the .vmx file:

ethernet0.virtualDev = "e1000"

When the virtual machine was restarted, Windows 7 detected and activated the network card without a problem.

WinXP SP3 Breaks Automatic Updates

Windows XP Service Pack 3 can break the automatic updates under certain circumstances due to a DLL that may not be registered. If the update system starts to fail with messages like “updates not installed”, do the following:

  1. Stop the update service:
    net stop wuauserv
  2. Register the DLL:
    regsvr32 %windir%\system32\wups2.dll
  3. Restart the update service:
    net start wuauserv

The update service should work again.