Coder Social home page Coder Social logo

nonsie / my-first-blog Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gsong/my-first-blog

0.0 1.0 0.0 54 KB

A Docker based starter template for the Django Girls tutorial

License: Apache License 2.0

Makefile 9.44% Shell 15.40% Dockerfile 4.77% Python 48.51% Batchfile 6.65% HTML 11.22% CSS 4.02%

my-first-blog's Introduction

Docker Based Django Girls Tutorial Starter

In order to simplify the setup for Django Girls workshops, let's use Docker to set up most of our development environment.

Caveat: These instructions have been tested thoroughly on macOS, and should work just as well on most Linux based systems.

Windows users should refer to the Windows README.

Installation

Instead of following the directions in Django Girls Tutorial Installation, follow these setup instructions instead.

  1. Install Dockerβ€”follow the instructions for your specific operating system. If installing on Ubuntu, you can use the install-docker-ubuntu.sh script included in this repository, or see Additional Notes for Ubuntu section below.

  2. Sign up for a free GitHub account, if you don't have one already. If you do have an account, make sure you can login with your username and password.

  3. Make a copy of this repo into your own account by forking this repo. To do this, click on the "Fork" button at the top of this page.

  4. Take a little time to read through "Introduction to the command-line interface", so you can be familiar with how to use your command line interface ("CLI").

  5. Open a CLI window (also known as terminal) to setup the project:

    cd /tmp
    curl -OL https://cdn.jsdelivr.net/gh/gsong/my-first-blog/setup.sh
    source setup.sh
  6. Install a code editor.

    Here's a list of editors to consider. All of them will work for macOS, Linux, or Windows. In order of biased preference:

  7. Create a PythonAnywhere account.

These steps will set up your project in ${HOME}/src/djangogirlsβ€”in other words, the src/djangogirls subdirectory in your home directory.

πŸŽ‰ You're ready to start the tutorial! Continue with How the Internet works. Note some minor changes you'll have to keep in mind as you follow the tutorial.

Additional Notes for Ubuntu

  • If you're installing Docker on Ubuntu 19.10 Eoan, in the command to add the Docker repository to your system, change $(lsb_release -cs) to disco. This is because Docker does not have official repositories for Eoan yet, so we use the repository for the previous version (Disco).
  • Make sure to follow the Manage Docker as a non-root user steps in Post installation for Linux instructions, so that you can run docker without sudo.
  • Make sure to also install docker-compose before running make cli.

Changes From the Tutorial

Command Line Operations

You'll be using Docker containers throughout the tutorial to do your work. It's best to keep two CLI windows open at the same time: one to run the command line, and another to run your web server.

Command Line

πŸ‘‰ Whenever you see mention of "open up a command line":

  1. Open up a CLI window

  2. Navigate to the project directory

    cd ${HOME}/src/djangogirls
  3. Start an interactive container:

    make cli

There's no need to activate a virtual environment, since our Docker container is our virtual environment.

Instead of the prompt you see in the tutorial instructions:

(myvenv) ~/djangogirls$

You'll instead see:

${YOUR_USERNAME}@app:~/src/djangogirls$

You can leave the Docker container by entering the command exit.

Run Django Web Server

πŸ‘‰ Whenever you see mention of python manage.py runserver, use the following instead:

make runserver

This will start the Django web server in a container, and will behave exactly as described in the tutorial.

If you get an error message, make sure that you're not still in the docker container after running make cli. If you are, you can either open a new command line tab to run make runserver in, or first exit make cli with exit.

Skip the Following Sections

Since we're simplifying the installation process, you can skip (completely or mostly) the following sections:

Minor Changes

Instead of setting:

ALLOWED_HOSTS = ['127.0.0.1', '<your_username>.pythonanywhere.com']

Set it to:

ALLOWED_HOSTS = ['*']

Hints on Window Management

During the course of the tutorial, you'll need to juggle lots of different windows. This is one suggested way to arrange the different windows on your screen. You should have three applications running:

  1. Command line interface console
  2. Browser
  3. Editor

CLI Console (aka Terminal)

You should have two windows or tabs for working with the command line. Keep one dedicated for typing and running commands, and another one for running the Django web server, which you'll rarely need to touch.

If you use two windows, it's easier if you stack them top and bottom.

Browser

Use two separate windows to manage all the pages.

Window #1

Lay out your first window with the following tabs, in order:

Keep this window persistent and consistent throughout your day.

Window #2

Use this window for any research you need to do.

Editor

Make sure your editor is rooted to ${HOME}/src/djangogirls for convenience. Each editor will have its own way of accomplishing this.

Enhancements

IPython

Instead of the plain Python console, we've installed IPython, which is much more powerful. To use it, just type ipython in place of python or python3.

Autocompletion

Since CLI commands are sometimes complex and prone to typos, we use autocompletion to help us with the task. To use autocomplete, simply press the TAB key, and your computer will make suggestions.

The Docker image has the following autocompletion installed for your convenience:

  • bash: Unix commands, path names
  • Django: management commands (i.e. python manage.py …)
  • IPython: Python modules, classes, methods, functions, etc.
  • Git: git subcommands

Command History

Both bash and ipython have command history enabled. This means you can use ↑ (up arrow) to access commands you've typed before, even across multiple sessions.

my-first-blog's People

Contributors

gsong avatar nonsie avatar mike-ce avatar lindboe avatar demophoon avatar pastelmobilesuit avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.