Prepping for Django

CodingWeb DevelopmentDjangoPythonSoftware

In my free time I’ve been trying to dive deeper into alternative web-frameworks and coding languages. Python has been my primary target for its ease-of-use and ubiquity among the web’s top development languages.

In my experiences learning Python I have found that it’s actually quite similar to Ruby. It’s a lot less cumbersome than C or C++ and it has some killer docs to support both beginner & intermediate programmers. In fact, the “create your own first Django app” is one of the best resources I have found out there.

With the hopes to start in a casual coding internship role soon, I took to developing a Python & Django prep guide for my friend, Stephen, at SCOOPR Media. Learning about Django and getting setup on both PyCharm & VirtualEnvironment was difficult and is still confusing, but this guide covers the basics. Enjoy!

The most updated prep file can be found here

alt text

Django Prep for SCOOPR Internship

Lead Software Engineer: Stephen Estrada

Software Intern: Austin Hay

Updated January 5, 2014

1. Get comfy with CL and learn to create REPO remotely from CL.

There are a few ways to do it. You could create a custom command in bash, use the API tools from Github, or use HUB, which adds a bunch of cool features. I did it the gritty way – with straight Github API.

curl -u USER -d "{\"name\":\" $REPO_NAME\"}"

Next, you (might?) need to add the remotes:

git remote add origin
git push origin master

USER & REPO_NAME should be replaced with their respective values.

There’s a cool bash script that automates this process, but I’m not sure if this is kosher with your crew, Stephen.

Sidenote: cURL is an awesome CL tool that I spent a good amount of time learning about. The cURL tags are where the magic is at.

2. Create a virtualenv wrapper for your new repo:

Step A. Getting Up to Speed on VirtualEnv

Follow the link to the virtual wrapper docs.

$ sudo pip install virtualenvwrapper
$ cd
$ ls -a
$ cat << EOF >> .bashrc 
	export WORKON_HOME=$HOME/.virtualenvs
	export PROJECT_HOME=$HOME/Devel
	source /usr/local/bin/

It’s really important that you use >> on the right hand side of EOF. If you use > then you’ll override your whole .bashrc file. I learned this the hard way…

Finally, reload the startup file:

$ source ~/.bashrc

What I learned about Virtual Wrapper so far…

  • virtualenvwrapper is a virtual environment tool extension that includes wrappers for creating and deleting virtual environments and thus managing development workflow. This makes it easier to work on more than on project at a time without introducing conflicts in the project’s dependencies.

  • The variable WORKON_HOME tells virtual wrapper where to place your virtual environments. Default is $HOME/.virtualenvs.

  • VWrapper is customizable @

  • At startup, Vwrapper finds the first python and virtualenv programs on $PATH.

Step B. Creating a wrapper around a Github Repo

A great walkthrough is available online. But there are many others as well. We all love StackOverflow.

First, navigate to the directory where you’ll store your Django projects.

git clone [https://etc.etc.REPO_NAME] # Just grab the url from Github if you have trouble.
mkvirtualenv --no-site-packages REPO_NAME
$ touch requirements.txt
$ cat << EOF > requirements.txt
$ pip install -r requirements.txt 

Make sure your virtualenv is activated when you run this comand so that pip will only install these packages for this specific virtual environment.

All of these requirements were what I found to be useful. This could totally vary on the project. The purpose is mostly to demonstrate how to load custom packages into a virtual environment for use in further development.

Beyond this, there’s so much more that I don’t fully understand about virtual environment; this includes Pylons and a bunch of other stuff. At the very least this will get us off the ground and running. Afterwards, it would be good to check out more virtual environment documentation to fully understand what’s going on.

3. Download PyCharm and play with it

Download it and play around with it.

4. Make the Django Tutorial Project

Instructions can be found here.

5. Final Notes

This internship will be focused on front-end engineering, so keep in mind the static files architecture and proper placement methodologies.

Become familiar with other web development frameworks, such as Sinatra, Rails, etc. Django is also considered an MVC framework, but goes by another name MVT. Do some research on it.

Additional (awesome) Resources: