Skip to main content
Redhat Developers  Logo
  • Products

    Platforms

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat AI
      Red Hat AI
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • View All Red Hat Products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat Developer Hub
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat OpenShift Local
    • Red Hat Developer Sandbox

      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Secure Development & Architectures

      • Security
      • Secure coding
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • Product Documentation
    • API Catalog
    • Legacy Documentation
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

Learning Django with OpenShift

May 14, 2013
Scott McCarty (fatherlinux)
Related topics:
Kubernetes
Related products:
Red Hat OpenShift Container Platform

Share:

    Background

    The goal of this article is to use the OpenShift Platform as a Service (PaaS) as a learning platform for Django. Most of the technical articles out there about running Django on OpenShift assume the user already understands how to administer Django environments and projects. This article is written from the perspective of someone who has done some python programming and wants to learn some Django without doing a bunch of setup work.

    Since each OpenShift Gear "...is a container with a set of resources that allows users to run their applications", a user can ssh in to test, troubleshoot, debug and learn. This turns out to be quite convenient for learning Django.

    Django Quickstart

    First, we must deploy an OpenShift application. The deployment is completely automated with the Django Quickstart. Once completed, the web interface will return all of the connection information necessary for Django, Git, and SSH. Estimate 5 minutes.

    https://www.openshift.com/quickstarts/django -> Deploy Now

    Screenshot-Django-Quickstart

    Learning Environment

    Once the application and framework are set up, it's time to log in, do some basic configuration, and set up a developer workflow. This will allow us to focus on learning Django.

    Use ssh to connect to the OpenShift Gear and set up a few things. Luckily, most of the work is done for you by OpenShift. Use the connection information provided for your Gear when the OpenShift application was created in the last step.

    ssh 5179e2c7500446ddb7000023@django-fatherlinux.rhcloud.com
    Each OpenShift Gear has a small data directory where your application's database is stored. Conveniently, this can also be used for scratch work. Clone your application's git repo to your data directory. This is not recommended for a production application but will allow you to start learning Django from a Mac, Windows, or Linux Desktop without worrying if the correct version of Django is installed locally.

    git clone ~/git/django.git/
    Configure a few environmental variables to make your workflow easier

    cd ~/app-root/data/django/wsgi/openshift
    echo "cd ~/app-root/data" >> ~/app-root/data/.bash_profile
    source $OPENSHIFT_HOMEDIR/python-*/virtenv/bin/activate

    Here are a couple of tests to verify that the Django environment is working correctly:

    python -c "import django; print(django.get_version())"
    python manage.py shell

    Practice Workflow

    Login from scratch and create a new Django Application to get comfortable with the workflow. These are the basic instructions to follow every time you connect to the learning environment. We are doing a couple of things here. First, we are creating the application with the Django admin utility, which creates a new directory. Then we add the directory to our GitHub repository and commit the change. Finally, we are pushing the change, at which point, OpenShift will take over and perform all of the necessary steps to make your application live.

    ssh 5179e2c7500446ddb7000023@django-fatherlinux.rhcloud.com
    source $OPENSHIFT_HOMEDIR/python-*/virtenv/bin/activate

    python manage.py startapp mytest
    git add mytest
    git commit mytest -m "Created test application"
    git push

    Start Django Tutorial

    The six-part Django Tutorial is great, but there are a couple of things to be aware of when working in an OpenShift environment. First, having your git repository checked out in the OpenShift Gear is only a good idea for a learning environment. Second, the portion of the tutorial called The development server will not work properly because the Django Quickstart configures and adds the OpenShift components necessary to start the Django application for you.

    ssh 5179e2c7500446ddb7000023@django-fatherlinux.rhcloud.com
    source $OPENSHIFT_HOMEDIR/python-*/virtenv/bin/activate

    At this point, you can run through the tutorial, modify the data model, and interact with components in the shell, have fun!

    Last updated: August 16, 2022

    Recent Posts

    • Splitting OpenShift machine config pool without node reboots

    • Node.js 20+ memory management in containers

    • Integrate incident detection with OpenShift Lightspeed via MCP

    • One model is not enough, too many models is hard: Technical deep dive

    • What's new in Ansible Automation Platform 2.6

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2025 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue