A task came up in Google Code-in which asked me to install the django-netjsonconfig module by OpenWISP. Furthermore, I’m also supposed to share the challenges I faced during the set-up process as a sort of feedback. I’ll be trying be concise in this post so, without further ado, I’m beginning with this post.
The installation instructions for this this module have been well-documented on its
GitHub repository. So I began the installation by creating a Python 2.7 Virtual Environment using
python2 -m virtualenv py2 for the sake of cleanliness on my local machine. I chose
python2 for since for this since I was also on the lookout for bugs in the module and most of the bugs seem to be related with it since it’s a bit outdated now.
I then activated the
virtualenv and started entering the installation commands according to the instructions in the repository. Everything went on smoothly until the
python setup.py develop command. I got an error as shown in the below picture.
Clearly, the error suggests that Django v2.0.1 was being downloaded which isn’t supported by Python 2.7. A bit of browsing led me to the conclusion that the
setup.py needed to be modified to download older Django versions for Python 2.7. So, I added a simple
if-else block to the django installation statement as shown in the picture.
If you’re curious about my fix, this is the link.
Here, what’s being done is basically:
pythonversion used for installation using
- Install older Django versions if
sys.version_info<3, that is
- Install latest version if above condition isn’t satisfied, that is
I also had to remove the django installation line from
setup.py was fetching the requirement names from there. After applying this fix, I re-ran the
python setup.py develop command and there it was! The sweet smell of success. Now an older yet python2 compatible version of Django was being installed when using
python2 as clearly shown in one of the pictures below:
Older Django being downloaded
After this, I installed some more requirements using
pip install -r requirements-test.txt
This was how I’d finished installing
django-netjsonconfig using Python2. Now all that was left to do was to to do the migrations and run the server.
By referring to the instructions on the repo again, I opened the
did the migrations using
./manage.py migrate. It was really satisfying to see all the CLI responses coloured in green. 😄
After that, there was the superuser creation using
I started the test server using
./manage.py runserver and it was successful.
Server Up and Running!
I could also now visit the server at http://localhost:8000/admin.