Updating Django

django

#1

Hello.
When will Django framework be updated? Version 1.9 is pretty old and not officially supported anymore. There is Django 2.0 exists already.
I tried update it by myself in my workspace using virtualenv etc. but with no success.
I’m about to start a new project and it would be great to work with up-to-date software.


#2

You can do it like this:

virtualenv venv
source venv/bin/activate
pip install -U django

This will install latest stable version of Django.

If you want latest development version, you can install it like this:

virtualenv -ppython3 venv
source venv/bin/activate
pip install -e git+http://github.com/django/django#egg=Django

But be aware that it is not ready for production yet.


#3

To create an updated Workpace for Django 2.x, I find it’s easier to start with a blank workspace and use virtualenv as described by notapresent. Here are the steps I took to create a workspace for Django 2.1 with Python 3.6

  1. Make a new workspace using the “Blank” template
  2. Update apt-get (so we can install Python 3.6)
    sudo apt-get update
  3. Install Python 3.6
    sudo apt-get install python3.6
  4. Install virtualenv using pip3
    sudo pip3 install virtualenv
  5. Make a virtualenv for Python 3.6 (My virtualenv is named “venv” here)
    virtualenv --python=python3.6 venv
  6. Activate the virtualenv
    source venv/bin/activate
  7. Install Django (This should install v2.1 at the time of this writing)
    sudo -H pip3 install django
  8. Create your Django project (My project is just called “app”)
    django-admin startproject app

At this point, most tutorials I found have you start the server using the command line, but I wanted to be able to run my app using a cloud 9 runner so I could preview the results using the standard cloud 9 project url.

To create a custom runner to run this config (With the virtualenv):

  1. From the top menu choose Run > Run With > New Runner
  2. Use the editor to create your runner configuration. I started with the default Django runner code and added my “venv” activation path, and my project directory name (“app”)
    { "cmd": [ "bash", "--login", "-c", "source venv/bin/activate && cd app && python manage.py runserver $ip:$port" ], "working_dir": "$project_path", "info": "Your code is running at \\033[01;34m$url\\033[00m.\n\\033[01;31m" }
  3. Save the runner

Now you should be able to run your project using the cloud 9 runner. Your workspace should function similar to the old Django template, except now your terminal commands should be run using the activated virtualenv (and python3).